Skip to content

Fix keyboard interaction in search modal

Mark Florian requested to merge 417476-fix-home-end-search-modal into master

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

  1. Open global search modal (/ or s on most pages)
  2. Type in a search query
  3. 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.

Edited by Mark Florian

Merge request reports