NavList.Item: Go one level deeper for NextJSLikeLink #2079
Closed
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.
Demo: https://1hp8zb.csb.app/2-1
Demo code: https://codesandbox.io/s/nice-firefly-1hp8zb?file=/src/App.tsx&initialpath=/2-1
summary:
It's not necessary that the direct child of SubNav is
NavList.Item
, there are 3 possibilities:NavList.Item as={ReactRouterLikeLink}
: this one's pretty easy to check asaria-current
is still onNavList.Item
so checking direct children still works. sourceNextJSLikeLink: This one requires more work because the
NavList.Item
is nested one layer deep, but it's still predictable. sourceCustomNavLink: For this one, we cannot rely on children because the
aria-current
is hidden away from SubNav in a different component.While not ideal, we could provide some guidance on how to "extend"
NavList.Item
by asking folks to make sure thearia-current
is present at the site of usage like the second link here:It would be even better if we can detect this in dev environments and throw a warning linking to this guidance. source