Skip to content

fix(hooks): stabilize useKeyboardShortcuts keydown listener - #1241

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Nacho1499:fix/useKeyboardShortcuts
Aug 26, 2026
Merged

fix(hooks): stabilize useKeyboardShortcuts keydown listener#1241
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Nacho1499:fix/useKeyboardShortcuts

Conversation

@Nacho1499

Copy link
Copy Markdown
Contributor

Closes #897

PR Description:
Prevent the global document keydown event listener in useKeyboardShortcuts from tearing down and re-registering on every single render.
Previously, because commandMap depended directly on the commands prop, passing inline command arrays caused the map and handler references to change identity on every render. This forced useEffect to constantly remove and re-add the document event listener.
This update introduces a stable useRef approach to hold the active commands and shortcuts, ensuring the keydown listener is attached once while always reading the freshest closures.

Type of Change:
[x] Bug fix

Checklist:
[x] Code follows project style guidelines
[x] Self-review completed
[x] No console errors

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Nacho1499 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit b96364e into rinafcode:main Aug 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent useKeyboardShortcuts from re-registering the global keydown listener every render

2 participants