Skip to content

Commit 353d7af

Browse files
authored
Prevent default for input events that don't have any characters (#33)
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.
1 parent 2427b66 commit 353d7af

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/component/handlers/edit/editOnBeforeInput.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export default function editOnBeforeInput(
116116
// In some cases (ex: IE ideographic space insertion) no character data
117117
// is provided. There's nothing to do when this happens.
118118
if (!chars) {
119+
e.preventDefault();
119120
return;
120121
}
121122

0 commit comments

Comments
 (0)