Remove document key listeners on keyboard unmount - #6190
Open
evnchn wants to merge 3 commits into
Open
Conversation
DateInput applied .props('no-parent-event') to the inner QDate, but
Quasar 2.18.5's QDate has no such prop (noParentEvent belongs to the
anchor-props mixin behind QMenu/QTooltip). It was an inert no-op
attribute; removing it changes no behavior (open/close is driven by the
parent QMenu).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
`ui.keyboard` added document-level keydown/keyup listeners in `mounted()` but never removed them, so mounting inside a refreshable/sub_page and navigating away leaked N listeners per mount. Store the handler refs and remove them in `unmounted()`, mirroring `fullscreen.js`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 tasks
evnchn
marked this pull request as ready for review
July 25, 2026 06:17
falkoschindler
self-requested a review
July 26, 2026 20:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add a ui.keyboard inside a conditional/refreshable UI or a sub_page, then navigate away or toggle it off and on repeatedly. Every mount adds N document-level listeners (default keydown+keyup = 2) that are never removed; each keypress after teardown still runs the orphaned handlers and emits key events through disconnected components. Listeners and component instances accumulate without bound.
Minimal reproduction (
nicegui/elements/keyboard.js:4) — the exact test/script that was run to reproduce it:→
> assert leaked == 0, f'BUG REPRODUCED: {leaked} orphaned document keydown listeners after {N} mount/unmount cycles (expected 0)'Implementation
Added unmounted() to keyboard.js storing [event,handler] pairs at mount and removing them on unmount (mirrors fullscreen.js).
Verification
./nicegui· pylint 10.00/10 · pytest (touched) — all green.Progress