Skip to content

Keep Backspace and Delete inside the active contenteditable - #1353

Open
2836048681 wants to merge 1 commit into
testing-library:mainfrom
2836048681:fix/1239-bound-contenteditable-deletion
Open

2836048681 wants to merge 1 commit into
testing-library:mainfrom
2836048681:fix/1239-bound-contenteditable-deletion

Conversation

@2836048681

Copy link
Copy Markdown

What

Backspace and Delete in an empty contenteditable now leave neighboring text intact and emit no input event.

Why

With an empty editor between two paragraphs, calling user.type(editor, '{Backspace}') removed a character from the preceding paragraph. '{Delete}' removed a character from the following paragraph. Both emitted an input event on the editor.

How

Only expand a collapsed deletion range when both the caret and the next cursor position are inside the active editor. The regression tests call user.type with each key and check the editor, both paragraphs, and the input events.

Validation

  • Both regression cases fail on the original source and pass with the fix.
  • npm run validate and TypeScript declaration generation pass.
  • The package bundling command fails at SWC initialization on both the original checkout and the fix in this environment.

Fixes #1239.

This branch has not been deployed

No deployments
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.

input event is raised on empty contenteditable element

1 participant