-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigation Component: Search Control in Menu Titles #25315
Conversation
Size Change: +2.82 kB (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
835cd6b
to
654836e
Compare
@david-szabo97 Let me loop you in on what I'm proposing here, which contains some changes on the navigation tree structure. tl;dr: we have the tree, let's use it! 😄 Item
|
Looks good to me! Any reason to use
Too bad, probably it's still cheaper to loop through than |
This looks promising: https://github.com/fernandopasik/react-children-utilities/blob/master/docs/only-text.md |
It was both to distinguish it from the components props, and to avoid clashing with a hypothetical
The implementation recurses through all children, which could be expensive with a lot of complicated custom items. Just throwing out a random idea: what if we had a |
Well, this is the least expensive way to do it. I'm not sure if it's developer friendly though. It's a good starting point and we might need this for something else as well. (NavigationItem's label might not be the best describing text for searching in every case) |
Yup. |
24613fb
to
4776170
Compare
I think the icon should be white, not blue. -- I noticed the focus outline gets cutoff for the search button. -- As I'm searching, I expected to be able to use the up/down arrow keys to navigate the search results. -- I'm able to use the -- I expect to be able to hit the |
e5e3d2b
to
25f33f9
Compare
I was a bit confused because I didn't read the testing directions properly and was trying to figure out why the search wasn't showing up in the Site Editor sidebar. But now that I tested in Storybook, it looks and works well for me. I wasn't sure if it would search only within the subsection (Controlled Search) but the placeholder adapts nicely to that ("Search in Controlled Search"), which is a nice touch. But coming back to my initial confusion, are we intending to use the search on the Site Editor sidebar? |
*/ | ||
import { deburr } from 'lodash'; | ||
|
||
// @see packages/block-editor/src/components/inserter/search-items.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it worth opening an issue to extract this as a util function? So we can reuse it in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes definitely!
My intention was to open a follow up right after merging this, and this is a nice reminder, since at this point I'm sure I'd have forgot about it. 😄
Moving into a submenu, the focus is lost. I'm not sure what would be the best a11y-wise. Maybe we should focus on the first item or the back button? 🤔 EDIT: I don't think this is a blocker. Fine in a separate PR so we can merge this and get the ball rolling. |
@mattwiebe Yes.
@david-szabo97 I see what you mean... 🤔 Probably not a big deal, and not really related to the search function. 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing fine for me and the code looks good! 🚀
Description
Introduce a new
NavigationMenuTitle
component that can optionally become a search box, filtering the menu items.Fixes #25252
Things to do
appear
animation instead ofslide-in
. This is because the parent component usesslide-in
, and for some reasons whenever I toggle the search box, both animations would be triggered. (Solved: it was caused by the input gaining focus during the animation, which scrolled it into view, messing up the animation.)My intention would be to make the input field to look like the inserter search box, which is heavily customized and requires more involvement than I initially thought.(Not worthy: a normalTextControl
will do just fine)Maybe externalize the(It has a very low footprint and it's used by several other components already. We might want to create a general utility for it, but this is not the right place.)normalize
function, also used by the inserter search.NavigationGroup
.onSearch
function to handle custom search logic (this might require its own example in the storybook).Explore if there's a simple way to search inside items rendering custom components.(Discussion moved to Navigation Component: What to Search and How #25509)How has this been tested?
npm run storybook:dev
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: