Skip to content

fix: split space-separated event names in input listeners (@zacharybergin) - #8389

Open
zacharybergin wants to merge 1 commit into
monkeytypegame:masterfrom
zacharybergin:fix/input-listener-event-names
Open

fix: split space-separated event names in input listeners (@zacharybergin)#8389
zacharybergin wants to merge 1 commit into
monkeytypegame:masterfrom
zacharybergin:fix/input-listener-event-names

Conversation

@zacharybergin

Copy link
Copy Markdown

Description

addEventListener only takes one event name at a time. So "copy paste" and "select selectstart" were not really registering both events.

This meant copy and paste into the words input was never actually being blocked. It looks like the space separated syntax was left over from the jQuery .on() code before the input rewrite in #7119.

I split these into separate listeners so each event should actually be registered correctly.

One thing I noticed is that fixing selectstart also makes the selection blocking work again. It's been broken since #7119. So this is technically a behavior change and not just a bug fix. Let me know if you'd rather I leave that part out.

Also select isn't cancelable so preventDefault() doesn't really do anything for that event.

Closes #8361

addEventListener matches the type argument as a single literal string, so
"copy paste" and "select selectstart" registered listeners for events that
can never fire. Both are jQuery .on() syntax, which accepts space-separated
lists; the DOM API does not.

Register each event separately so copy/paste prevention on the words input
works as intended.
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Sep 4, 2026
@fehmer

fehmer commented Sep 4, 2026

Copy link
Copy Markdown
Member

duplicate #8371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: copy/paste prevention listeners never fire — space-separated event names passed to addEventListener

3 participants