Found while investigating #3159.
Current situation
The v-oc-tooltip directive (packages/design-system/src/directives/OcTooltip.ts) registers a keydown listener on document for every element it is bound to, and only removes it on unmount.
File list rows are never unmounted once revealed, so the listener count grows with every item scrolled past.
Measured on a 500-row table:
|
document keydown listeners |
| after initial load |
135 |
| after scrolling through all 500 rows |
3021 |
That is about 6 per row.
Why this is bad
Every keystroke anywhere in the app fans out to three thousand handlers, each of which only needs to check for Escape. It gets worse the longer a session runs and the more large folders are visited. There is no upper bound.
Proposed solution
Register a single shared keydown handler for the directive that closes whichever tooltip is currently open, instead of one handler per bound element. The per-element mouseenter/mouseleave/focus/blur/click listeners can stay as they are.
Verification
document keydown listener count stays constant across a full scroll pass through a large folder.
Found while investigating #3159.
Current situation
The
v-oc-tooltipdirective (packages/design-system/src/directives/OcTooltip.ts) registers akeydownlistener ondocumentfor every element it is bound to, and only removes it on unmount.File list rows are never unmounted once revealed, so the listener count grows with every item scrolled past.
Measured on a 500-row table:
documentkeydown listenersThat is about 6 per row.
Why this is bad
Every keystroke anywhere in the app fans out to three thousand handlers, each of which only needs to check for
Escape. It gets worse the longer a session runs and the more large folders are visited. There is no upper bound.Proposed solution
Register a single shared
keydownhandler for the directive that closes whichever tooltip is currently open, instead of one handler per bound element. The per-elementmouseenter/mouseleave/focus/blur/clicklisteners can stay as they are.Verification
documentkeydown listener count stays constant across a full scroll pass through a large folder.