Skip to content

Commit

Permalink
Prevent default for input events that don't have any characters
Browse files Browse the repository at this point in the history
Seeing cases where some input events with `inputType=deleteContentBackward` are slipping through. These are probably being created via some mechanism other than a keydown directly on the script (e.g., through some accessibility API, or touch control, or some event that's being targeted elsewhere but propagating to the script accidentally).

We _never_ want draft.js to do anything in response to an `onInput` in our user case. We were relying on our passed-in `handleBeforeInput` to always return `handled`; but we're only hitting that logic when the input event contains characters. This will hopefully fix that.
  • Loading branch information
srubin committed Oct 30, 2024
1 parent 2427b66 commit 3552fb4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/component/handlers/edit/editOnBeforeInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default function editOnBeforeInput(
// In some cases (ex: IE ideographic space insertion) no character data
// is provided. There's nothing to do when this happens.
if (!chars) {
e.preventDefault();
return;
}

Expand Down

0 comments on commit 3552fb4

Please sign in to comment.