Opened 7 weeks ago
Last modified 6 weeks ago
#66233 new enhancement
Toolbar: one search entry point for the admin and the front end
| Reported by: | lucasmdo | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Toolbar | Version: | |
| Severity: | normal | Keywords: | needs-patch needs-design-feedback |
| Cc: | Focuses: | ui, accessibility, javascript, css, ui-copy |
Description
This ticket proposes one search entry point in the Toolbar. The front end gets the same search item the admin has, in the same place and with the same shortcut.
Current behavior
The Toolbar has two search controls. They share the same icon, but they work in different ways.
- In the admin, the item sits on the left, after the site name. It shows the icon and the shortcut (⌘K or Ctrl+K) and it opens the command palette.
- On the front end, the item sits on the far right, after the account item. It is a field that expands on focus and opens the site search results. It has no shortcut.
On small screens the front-end search is hidden, so the Toolbar has no search there.
The field is also the reason the account item is not the last item on the right on the front end. Which create an odd inconsistency.
Proposal
- Remove the search field from the right side of the front-end Toolbar.
- Show the same item the admin has, in the same position, with the same icon and shortcut.
- On the front end, the item and the shortcut open a small dialog with one field: "Search the site". Enter opens the site search results, same as today.
- In the admin nothing changes. The item opens the command palette.
The dialog follows the look of the command palette, so both read as the same control.
No React, almost no weight
This proposal does not bring the command palette to the front end.
The dialog is a native <dialog> element with a plain search form. It needs no React and no editor packages. In my prototype it adds around 4 KB for logged-in users. For comparison, loading the command palette on the front end added around 1.6 MB of scripts (uncompressed) in the same test.
The weight was the main concern when the command palette on the front end was discussed before. This approach avoids it.
Why
- One mental model. One icon, one place and one shortcut to search, in the admin and on the site.
- The item does not move. The Toolbar is the only part of the interface that follows the user between the site and the admin. I believe its controls should stay in the same place when the user crosses.
- The account item becomes the last item on the right in both contexts.
- More space on the right side, where plugins and hosts add their own items. Same goal as #66157.
- Search comes back on small screens.
- Nothing is lost. The search does the same thing it does today.
Accessibility
- The same shortcut works in both contexts.
- The dialog moves focus to the field when it opens. Escape closes it and focus returns to the Toolbar item. The browser handles this natively.
- The field has a clear name, "Search the site". Today the label is only "Search".
- The Toolbar keeps its layout on focus. Today the field grows inside it.
- Without JavaScript, the item can be a plain link to the search page.
- RTL: no change, the item mirrors as in the admin.
Backward compatibility
- The search request is the same (
?s=). Themes and search plugins keep working. - Code that removes the search item keeps working, there is nothing to remove.
- Custom CSS for the old field stops applying.
- "Search the site" is a new string.
Follow-up
The command palette could use the same label and offer a "Search the site for …" result. Then both contexts answer the same way. This part lives in Gutenberg, so it needs its own issue.
Related
- #65221 has the same goal and keeps the field on the right. This ticket goes one step further.
- #64672 added the command palette item to the Toolbar.
- #64875 discusses the position of that item.
- #26940 is an older proposal for the front-end search.
- #66157 frees space on the right side.
- Gutenberg #73708 discussed the command palette on the front end.
Attachments (3)
Change History (5)
#2
@
6 weeks ago
I checked this against current trunk, and the proposal is relevant. The front end still uses the expandable search node under top-secondary, while the command-palette item is admin-only. The front-end search also remains hidden at mobile widths.
Before implementation, I think we need design feedback on a few details:
- Should the front-end item retain the existing search node ID and wp_admin_bar_search_menu() callback for compatibility with code that removes it?
- What should the no-JavaScript fallback be? An empty ?s= URL is not necessarily a reliable search landing page across themes.
- Should Cmd/Ctrl+K exactly mirror the admin behavior, including toggling the dialog and overriding the browser shortcut?



I believe I also suggested this in https://core.trac.wordpress.org/ticket/64672#comment:24
An implementation was explored in https://github.com/WordPress/wordpress-develop/pull/11160