Skip to content

fix(selection): skip contenteditable=false in caret placement - #1313

Open
erikpukinskis wants to merge 1 commit into
testing-library:mainfrom
erikpukinskis:fix/skip-contenteditable-false-caret
Open

fix(selection): skip contenteditable=false in caret placement#1313
erikpukinskis wants to merge 1 commit into
testing-library:mainfrom
erikpukinskis:fix/skip-contenteditable-false-caret

Conversation

@erikpukinskis

Copy link
Copy Markdown

What

Skip contenteditable=false elements when deciding where to place the caret

Why

Rich text editors like Slate use contenteditable elements 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 contenteditable are actually editable.

How

Additional logic added to resolveCaretPosition

Checklist

  • Documentation — n/a
  • Tests
  • Ready to be merged

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.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant