Repository navigation
Dealing with leftover separators when hiding menu items #4164
Unanswered
Stevoisiak
asked this question in
Q&A
Replies: 1 comment 4 replies
As usual, without a specific URL where I can investigate, I can't proposed a solution which I think may work. Without being able to try for myself, I would target a separator followed by a separator, something like: |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When filtering items in a menu that has separators between sections, is there a best practice for avoiding extra separators being left behind near empty sections?
For example, take this dropdown menu that appears on various GitBook powered sites:
When I filter the AI buttons, extra separators are left behind.
My current solution is to individually target the separators that need removing:
However, this is fragile and can break for menus where the contents aren't always the same. For example, the above filters work on
https://gitbook.com/docswhere there's an "edit on github" section at the end, but leave an extra separator onhttps://help.quantower.com/quantowerwhere that section is missing. Similarly, sites like Google Docs vary the menu options depending on the user or the type of document being opened.One idea I couldn't figure out how to implement was using filters that changed based on whether other items were hidden. So for example, check all non hidden items and have 3 rules: If 2 dividers are next to each other, hide one of them, hide dividers at the end of the list with no items afterwards, and hide dividers at the start of the list with no items before them. While I could accomplish that using
:remove(), that method is slower than CSS hiding, and can sometimes have unexpected effects when navigating menus with keyboard arrows.Is there a better way to handle excess separators in menus after hiding menu items?
All reactions