fix(selection): skip contenteditable=false in caret placement - #1313
Open
erikpukinskis wants to merge 1 commit into
Open
fix(selection): skip contenteditable=false in caret placement#1313erikpukinskis wants to merge 1 commit into
erikpukinskis wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Skip
contenteditable=falseelements when deciding where to place the caretWhy
Rich text editors like Slate use
contenteditableelements rather than standard inputs. These sometimes contain a mix of editable and non-editable elements (such as line numbers). When a user clicks one of these elements, browsers will not place the cursor in a non-editable element.However, current user-event behavior ignores whether children of a
contenteditableare actually editable.How
Additional logic added to
resolveCaretPositionChecklist
Notes
I also have a HappyDOM PR capricorn86/happy-dom#2248 out that resolves some related issues. Together, these PRs made Slate testable in testing-library, which wasn't doable before without a lot of hacks.