Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent default for input events that don't have any characters #33

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

srubin
Copy link

@srubin srubin commented Oct 30, 2024

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.

(All of the Sentry errors that show an input event slipping through have the inputType deleteContentBackward, e.g., https://descript-inc.sentry.io/issues/5906595861/events/ccbc41ddbc754203babb78ff9d929d93/?project=1197057&referrer=previous-event)

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.
@srubin srubin self-assigned this Oct 30, 2024
@srubin srubin requested a review from scottcheng October 30, 2024 18:43
@scottcheng
Copy link

nice catch!

@srubin srubin merged commit 353d7af into main-pojo Oct 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants