Issue #3624439: Alt + a search shortcut: Look up visible elements and guard a missing search tab

The Alt + a handler in admin_toolbar_search.keyboard_shortcut.js looked elements up with getElementById() and called getComputedStyle() on the search tab without checking it exists.

  • When the administration_search toolbar item is removed (for example in hook_toolbar_alter()), every Alt + a threw a TypeError.
  • When the toolbar is rendered more than once (Gin with the new navigation layout), the first match for #admin-toolbar-search-field-input is in a hidden toolbar and focus() does nothing.

The handler now picks the first visible element for each ID. A visible search field is focused directly. Otherwise the visible search tab's tray is toggled and its input focused, as before. When neither is present it returns without calling preventDefault().

AdminToolbarSearchEventsTest::testAdminToolbarSearchKeyboardShortcutSearchField() covers the search field in the toolbar, a hidden duplicate placed before it, a page without the search tab, and a page with nothing to focus. The existing tray tests are unchanged.

Closes #3624439

Merge request reports

Loading
Loading