-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 block: Hide more than N items #27131
Comments
@scruffian I'm taking a look at this one and trying to figure out how to surface this so it is available to themes. Playing with a Codepen (https://codepen.io/mkaz/pen/zYKMyLw) and seeing if possible to use the |
The way that themes would use it would be through theme.json. I think you're right there would need to be some changes to the markup to make this work. Is that a problem? |
Ideally, this shouldn't be a set number of items... Instead, it should just hide the items that don't fit. This way it will work for all viewports with minimal changes |
@aristath yes that would be much better! |
Essentially what we need is in this codepen. I wish that were possible with no JS — I think we could actually come as far as menu items disappearing one by one and a menu appearing only when necessary. The tricky bit here is, I don't know how we'd keep track of which items to show in the overflow menu or not. So I believe we do need some JS at least handle what shows up in the menu and what doesn't. |
Hmmm thinking about this some more, perhaps we don't even need to collapse them vertically? This codepen uses a lot of JS and I'm just using it to show an alternative concept, but it is conceivable we can build something like that (but obviously better) using plain CSS 🤔 |
Scrolling horizontally, perhaps with a button to indicate the overflow, we could probably do that as a baseline minimal responsiveness for menus. But I think there's value in the proposal here, which pops off the items into a dropdown menu. That is, if it doesn't get onerously complex once we have submenus on end — those obviously have to be handled elegantly by the overflow menu also. |
Another option is to take inspiration from @shaunandrews' "full screen menu" concept outlined in #24604. Basically, as soon as there isn't room for a menu item, a button shows up, which when clicked, opens the entire menu in a fullscreen modal. |
I think from a theme perspective we'd like both approaches... |
I have mixed feelings about horizontal scrolling, particularly because scrollbars show up differently between browsers—some of them being very ugly.
I tried an approach that uses https://codepen.io/vcanales-the-styleful/pen/eYdXWgz It has a few things going for it:
And a few drawbacks and things that I couldn't figure out in the time I gave myself to give it a try:
I'd love to iterate on this if you think it's going somewhere :) |
Yep, I would consider this the very last resort of responsiveness. On mobile, it can be a good experience to swipe horizontally, though, so I think it's a nice option to have. I like this one a lot! It actually pretty directly solves the ticket as outlined. If Ben can take a look at the codepen to see how well it works, I would love to work with you on the next step of actually integrating it into the menu block. What do you think? |
Just a note to say we did tackle this in the past here Not sure if it will help but could be good context for what paths have already been explored. |
Absolutely!
I think we can leverage the wrap detection to stack wrapped elements vertically by moving them to another container. I'll give it a shot when I have a moment. |
There's some relevant discussion in #22824 also. Any PR that fixes this one, probably also fixes that older one. |
@MaggieCabrera this feels very similar to what you have tried in other PRs. What are your thoughts on this? Is it achievable to make this automatic vs having a hard coded number of items? @mikachan I'd also value your input from a Themes perspective on whether this feature is even desirable. |
My exploration was a little different but what I found is that we have two problems that we may or may not want to find a "smart" solution for:
The first one we could find a reasonable solution, potentially with just CSS and container queries. The second one not so much, since there is no way to know about how the user decided to build their header. Did they use grid? a row block? columns? It also happens that the second thing happens before the first, so it's the problem most use cases will want to fix. After trying and failing to solve this myself and discussing this with design, I think trying for a smart solution will not land a good solution, so maybe we need to think about how we want to expose the option to users. I think this is one of the cases where we need to wait for a more holistic solution on responsive controls before we find a specific solution for the navigation block |
Thank you for that helpful recap 🙇
...or do we need some blocks to push the boundaries and start introducing these controls behind experiments so when it comes to a holistic solution we have something to build upon? |
We've tried that with the nav block and it seemed like a very block specific solution |
From my experience, I don't believe this feature has been requested much by theme builders, although that's not to say it wouldn't be a helpful feature.
+1 for waiting for a more holistic solution to responsive controls before we address this on the Navigation block. |
It would be useful to have an option for the navigation block to set a maximum number of items, and then hide the rest, like this:
The text was updated successfully, but these errors were encountered: