-
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
[Try] Navigation Component: Internal groupings #25035
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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.
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.
I have a feeling that this is becoming a bit too magic, and had some problems following it (I'm not use to mutating stuff anymore 😅).
If I'm not mistaken, there is a lot of duplicated data in the resulting
items
Map, with data listed both nested and flat.I'm poking around with this function, trying to come up with a reasonably simpler version.
It's not simple, I'll give you that! 😄
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 will just become more complex over time, ideally we should move a way from "config" based API and use a component composition based one.
We have the same issue with DropdownMenu component where it's config based like the navigation one and unfortunately, we hit the limit on several occasions everytime we have a slightly different use-case.
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.
@youknowriad I've seen that
DropdownMenu
has 2 different interfaces, with config or children.Building upon the children one, we could do something like this for the Navigation:
With the
navigateTo
function controlling the whole toggle state and animation when traversing the menu hierarchy, and the variousNavigationItem
that could be either simple buttons or render anything inside.Although I think this would be very hard to filter. 🤔
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 something like that.
I actually think the current config implementation could be built on top of a more flexible API based on components composition. So we'd have one API and potentially a shortcut (not sure if needed on Core though).
I think @ItsJonQ had some similar ideas on explorations maybe on his G2 project?
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.
If we go this route though, it's probably a refactor that should happen separately and not block the current PR.
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.
Since the current implementation has reached some stability, a large refactor won't cause conflicts with ongoing work. We've been using
npm link
to thefeature/navigation
branch, so I'm ok to do a refactor before the merge.The challenge that jumps out to me is that not every navigation view will have sub menus and some will have multiple submenus. How would you compose a render function to handle all those possibilities? I will have a ponder on that today and take inspiration from @ItsJonQ 's code to see if I can find a solution.
Thanks for the feedback @Copons @youknowriad !
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.
I've opened a (very rough!) draft of the approach I outlined earlier: #25057
Apologize for its state, but I wanted to push out something to avoid losing a day (a whole weekend even?) due to timezone differences. 🙂
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.
Thanks for that draft @Copons! Overall I do like the compositional approach more.
However, we do shift most of the responsibility for determining active items and active levels to the consumer. If we're okay with this then I'm all for the refactor.
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.
is this something that we can provide using hooks and context. an API like that could be awesome:
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.
@youknowriad the current version of the composition approach #25057 does indeed use the Context API.
I haven't moved the "active" logic into a custom hook as it's very simple and straightforward, but nothing blocks us to do so.
At the moment, the consumers don't need to know or do anything about the internal state of the navigation (although they optionally can).