Fix co-ordinate issue with display: contents
nodes
#177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I observed a bug with a custom table component I have implemented, based on
prosemirror-tables
. The issue arises from a conditional check inposAtCaret
which will cause the position to use the doc.content.size when a zeroed out client rect is returned.This commit adds an extra conditional check which will ignore any elements that have zero width and height. This seems like a sensible solution to me but please let me know if this is unwise.
Before this fix
A DOM setup like
Would incorrectly return
table.posAfter
fromposAtCaret
instead of the pos of the internal<p
nodeThe problematic line is here
https://github.com/ProseMirror/prosemirror-view/pull/177/files#diff-8711f18f44af6275714f55277ddd18fb124ab348b03cd4b86a4fdb253b205330R241
An element with
display: contents
will have a zerod client bounding rect. So it will always descend into this branch.I believe my change will handle other edge cases where an element has a zero'd bounding rects