Skip to content

Command Palette: Make admin bar trigger a native group element#11171

Open
ellatrix wants to merge 3 commits intoWordPress:trunkfrom
ellatrix:tweaks/command-palette-admin-bar-searchbar
Open

Command Palette: Make admin bar trigger a native group element#11171
ellatrix wants to merge 3 commits intoWordPress:trunkfrom
ellatrix:tweaks/command-palette-admin-bar-searchbar

Conversation

@ellatrix
Copy link
Member

@ellatrix ellatrix commented Mar 5, 2026

Trac: https://core.trac.wordpress.org/ticket/64672

image
Screen.Recording.2026-03-05.at.09.53.12.mov

Summary

Follow-up to #11108. Makes the command palette trigger a native admin bar group element instead of a regular node in root-default, as suggested in review.

  • Registers command-palette as its own group under root using add_group(), with the trigger node inside it — this produces a sibling <ul> to root-default and top-secondary
  • Converts .quicklinks to display: flex so the three groups lay out naturally: left items, centered command palette, right items
  • Both side groups use flex: 1 1 0; min-width: fit-content — equal space when the viewport is wide (perfect centering), but they won't shrink below their content on narrow viewports
  • Command palette group uses flex: 0 0 auto between them

Existing float declarations on <li> elements become harmless (floats are ignored on flex items per CSS spec).

Alternative approach

An alternative would be to bypass the node/group API entirely and render the command palette directly in WP_Admin_Bar::_render() as a standalone <button> element — a sibling to the <ul> groups inside .quicklinks. This would give full control over the markup (semantic <button> instead of <a> inside <li> inside <ul>), but requires modifying class-wp-admin-bar.php and hardcoding the element into the admin bar's render method. The group-based approach here is more straightforward since it reuses the existing API and keeps all the command palette logic in admin-bar.php.

Test plan

  • Load any wp-admin page: command palette button should appear centered in the admin bar
  • Click it: should open the command palette
  • Check front-end pages: button should NOT appear
  • Resize viewport — left group should push the command palette rightward rather than shrinking
  • Test RTL layout
  • Test mobile viewport (admin bar collapse behavior)
  • Test different color schemes (modern, default)

🤖 Generated with Claude Code

t-hamano and others added 3 commits March 2, 2026 19:40
Instead of adding the command palette as a regular node in
root-default, register it as its own group under root. This makes
it a sibling `<ul>` to root-default and top-secondary, allowing
flexbox centering on `.quicklinks` without being constrained to
the `<li>` node structure.

- Add `command-palette` as a group with `add_group()`, place the
  trigger node inside it as `command-palette-trigger`
- Convert `.quicklinks` to `display: flex` for layout control
- Both side groups use `flex: 1 1 0; min-width: fit-content` so
  they share equal space but never shrink their content
- Command palette group uses `flex: 0 0 auto` to sit centered
  between them naturally

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wildworks, ellatrix, westonruter, ocean90, annezazu.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ellatrix ellatrix requested review from mcsf and t-hamano March 5, 2026 07:58
@westonruter
Copy link
Member

So the command palette is not accessible on mobile. Why shouldn't it be?

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

It's the same as #11108, I don't think I changed anything there. I guess it will have to be added explicitly to the mobile version of the admin bar

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! When I actually saw the center-aligned search bar, I realized it was quite prominent 😅

There are two things that concern me.

  1. With several plugins installed, the search bar may become misaligned:
    Image
  2. When I open the editor, you may find the search bar overlapping, which can be a bit confusing:
    Image

Personally, I think going with #11160 might have the least impact. What do you think? cc @sabernhardt

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

With several plugins installed, the search bar may become misaligned:

I think that's fine, it still looks ok?

When I open the editor, you may find the search bar overlapping, which can be a bit confusing:

What o you mean here? What overlaps what?

Personally, I think going with #11160 might have the least impact. What do you think? cc @sabernhardt

Would need approval from design

@ocean90
Copy link
Member

ocean90 commented Mar 5, 2026

Something that looks like an input/search field but isn't one feels wrong.

When I open the editor, you may find the search bar overlapping, which can be a bit confusing:

What o you mean here? What overlaps what?

They're not overlapping, but there are two of these bars right next to each other.

@t-hamano
Copy link
Contributor

t-hamano commented Mar 5, 2026

What overlaps what?

I was referring to these two places. There are two search bars close to each other that both trigger the command palette.

double-search-bar

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

@t-hamano Isn't that a problem in your PR too? How has it been addressed elsewhere? Or is there a proposal to unify them.

Something that looks like an input/search field but isn't one feels wrong.

@ocean90 It's the same for the editor document bar 🙂

@t-hamano
Copy link
Contributor

t-hamano commented Mar 5, 2026

Isn't that a problem in your PR too? How has it been addressed elsewhere?

Two approaches have been proposed that do not use a search bar in the first place.

@annezazu
Copy link

annezazu commented Mar 5, 2026

Personally, I think going with #11160 might have the least impact. What do you think?

Chatting with @mtias about this and a more condensed command‑K control is okay for beta 3 if needed, rather than the search icon. The search icon alone is not enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants