-
Notifications
You must be signed in to change notification settings - Fork 71
Make search shortcuts layout-independent #1162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughUpdates keyboard shortcut detection in Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant D as Document
participant H as Key Handler (bindOpenOnSlash)
participant S as Search UI
U->>D: Keydown
D->>H: Dispatch event
rect rgba(230,240,255,0.5)
note over H: Ensure target is not input/textarea/contentEditable
H->>H: Check event.code=='Slash' OR event.key=='/'
H->>H: Check (ctrl/meta) AND (event.code=='KeyK' OR event.key.toLowerCase()=='k')
H->>H: Check (alt+shift) AND (event.code=='KeyF' OR event.key.toLowerCase()=='f')
end
alt Shortcut matched
H->>S: event.preventDefault() + open search UI
else No match or disallowed target
H-->>D: return (no action)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)resources/skins.citizen.scripts/search.js (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
resources/skins.citizen.scripts/search.js (1)
125-150
: Optional: Consider applying this pattern to other keyboard handlers.The codebase has other keyboard event handlers (e.g.,
useActionNavigation.js
) that use onlyevent.key
withoutevent.code
. For consistency and improved layout independence, consider applying this dual-check pattern to other keyboard shortcuts in the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
resources/skins.citizen.scripts/search.js
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
resources/skins.citizen.scripts/search.js (1)
resources/skins.citizen.commandPalette/composables/useActionNavigation.js (1)
handleActionButtonKeydown
(67-124)
🔇 Additional comments (3)
resources/skins.citizen.scripts/search.js (3)
129-129
: Excellent improvement for keyboard layout independence!Adding
event.code === 'Slash'
alongsideevent.key === '/'
ensures the shortcut works across different keyboard layouts. Users can now trigger search by either:
- Pressing the physical key that produces "/" on QWERTY layouts
- Typing the "/" character on any layout
132-132
: Correct implementation for Ctrl/Cmd+K shortcut.The dual check for 'KeyK' and 'k' ensures this shortcut works reliably across keyboard layouts while maintaining backward compatibility.
136-136
: Consistent layout-independent implementation for Alt+Shift+F.The change correctly applies the same pattern as the other shortcuts, ensuring MediaWiki's standard search shortcut works across all keyboard layouts.
Please verify the shortcuts work correctly on different keyboard layouts (e.g., AZERTY, QWERTZ) to ensure the physical key positions and character inputs both trigger the expected behavior.
Update event checks to rely solely on event.code for shortcut detection.
Add
event.code
check in addition toevent.key
to work with any keyboard layout.This is mostly relevant for other languages, which require switching to English to use shortcuts.
Summary by CodeRabbit