Bug: copy/paste prevention listeners never fire — space-separated event names passed to addEventListener
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start in frontend/src/ts/input/listeners/misc.ts at the listener registrations on lines 12-19, then reproduce the copy, paste, select, and selectstart behavior on the hidden words input. Confirm that each intended event is handled separately and that the default browser behavior is prevented during a test.
Written by the indexing model from the issue text.
Description
Did you clear cache before opening an issue?
- I have cleared my cache
Is there an existing issue for this?
- I have searched the existing open and closed issues
Does the issue happen when logged in?
N/A
Does the issue happen when logged out?
Yes (source-code bug, independent of account state)
Does the issue happen in incognito mode when logged in?
N/A
Does the issue happen in incognito mode when logged out?
N/A
Issue details
Current Behavior
In frontend/src/ts/input/listeners/misc.ts, native addEventListener is called with space-separated event names (jQuery-style syntax), which registers literal event types that are never dispatched:
// frontend/src/ts/input/listeners/misc.ts:12-19
inputEl.addEventListener("copy paste", (event) => {
event.preventDefault();
});
//this might not do anything
inputEl.addEventListener("select selectstart", (event) => {
event.preventDefault();
});
The browser treats "copy paste" as a single event type named copy paste, so neither listener ever fires. As a result, copy/paste on the hidden words input is not actually prevented during a test.
Expected Behavior
Each event name should be registered separately:
for (const eventName of ["copy", "paste"]) {
inputEl.addEventListener(eventName, (event) => event.preventDefault());
}
(The select/selectstart pair should be evaluated separately — the inline comment already suspects it may be dead code and could possibly be removed.)
Steps To Reproduce
- Start a test.
- Focus the words input and attempt to select/copy text or paste into it.
- The default browser behavior is not prevented because the handlers were never attached to real event types.
Environment
- OS: Any
- Browser: Any
- Found via source review of
master@ 91bd24bb8
- Dominant language
- TypeScript
- Stars
- 20.7k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from monkeytypegame/monkeytype
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
monkeytypegame/monkeytype#8366 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
monkeytypegame/monkeytype#8365 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
monkeytypegame/monkeytype#8364 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
monkeytypegame/monkeytype#8363 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
monkeytypegame/monkeytype#8362 · 1 comment ·
All issues in monkeytypegame/monkeytype
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100