Issue #3624439: Guard Admin Toolbar Search JavaScript when the search tab is removed

If a site removes the Search tab in hook_toolbar_alter() and keeps only the search field, two scripts throw because they expect the tab to be there:

  • admin_toolbar_search.js errors on every page load when it adds the tab's click listener.
  • admin_toolbar_search.keyboard_shortcut.js errors on Alt + a, and the field never gets focus.

This checks for the tab first. The click listener uses ?., and Alt + a focuses the search field when there's no tab, or does nothing if neither is there.

The new test module admin_toolbar_search_test_no_search_tab removes the tab the same way. testAdminToolbarSearchKeyboardShortcutNoSearchTab() loads a page with it and presses Alt + a.

Closes #3624439

Edited by Jeremy Cerda

Merge request reports

Loading
Loading