You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that the CP nav can be customised I would like to group collections/taxonomies by subject rather than type, so instead of this:
- Collections
- Blog
- Taxonomies
- Blog Categories
I can just have this:
- Blog
- Categories
Which is totally possible!
The only problem is the nav hierarchy no longer matches the URL hierarchy, so when you click on Blog > Categories the Blog section closes and Categories is no longer visible.
This PR aims to resolve that by adding a NavItem::hasActiveChild() method, so that items can remain open when they have active children but aren't active themselves.
I see NavItem::children() can sometimes return a closure. I didn't want to mess with resolving children if it's not necessary, so I'm checking if it's a collection first. That may not be the best approach, I'm not sure, but it seems to work for this use-case.
So I ended up going with @jacksleight's approach, as it ended up being cleaner than my original idea. However, I noticed that this PR as it stands still resulted in issues with active status on the original section where the nav item was moved out of...
^ For example, in this example when on the 'Topics' page, the 'Taxonomies' parent item would still get flagged as active, and render its children, even if 'Topics' was intentionally moved out of this parent item.
Had to do a bit of a refactor around how we handle our isActive() checks, but got it figured out in #8685.
Anyway, just wanted to say thank you for the PR @jacksleight! This one was a bit of a doozie, and we always appreciate your efforts on this stuff! ❤️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that the CP nav can be customised I would like to group collections/taxonomies by subject rather than type, so instead of this:
I can just have this:
Which is totally possible!
The only problem is the nav hierarchy no longer matches the URL hierarchy, so when you click on
Blog > CategoriestheBlogsection closes andCategoriesis no longer visible.This PR aims to resolve that by adding a
NavItem::hasActiveChild()method, so that items can remain open when they have active children but aren't active themselves.I see
NavItem::children()can sometimes return a closure. I didn't want to mess with resolving children if it's not necessary, so I'm checking if it's a collection first. That may not be the best approach, I'm not sure, but it seems to work for this use-case.