Fix keyboard interaction in search modal
What does this MR do and why?
Fixes Home/End behaviour on the global search modal input.
Addresses #417476 (closed).
Commits
Name createComponent's parameters
This makes it easier to understand each call site, without having to refer to the function definition.
Correctly initialise KeyboardEvent
Use a more semantic selector
Add tests for existing keyboard behaviour
Always prevent default when result item has focus
This ensures the default behaviour of the keyboard event is consistently prevented when pressing ArrowUp while a result item has focus.
This doesn't fix a bug, but just an inconsistency revealed by the new tests.
Fix global search modal input Home/End behaviour
When the global search modal input has focus, pressing Home/End now moves the text cursor to the beginning/end of the input (i.e., the browser default behaviour), instead of focusing the first/last search results.
Note that this only makes sense for non-macOS users, for whom the Home/End keys by convention move the text cursor to the beginning/end of the line.
Addresses #417476 (closed).
Screenshots or screen recordings
Before | After |
---|---|
search_before | search_after |
How to set up and validate locally
- Open global search modal (/ or s on most pages)
- Type in a search query
- Press Home/End
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.