Skip to content
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

NavList.Item: Go one level deeper for NextJSLikeLink #2079

Closed
wants to merge 5 commits into from

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented May 17, 2022

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:

  1. NavList.Item as={ReactRouterLikeLink}: this one's pretty easy to check as aria-current is still on NavList.Item so checking direct children still works. source

    <NavList.Item
      as={ReactRouterLikeLink}
      to="/3-1"
      aria-current={window.location.pathname === '/3-1'}
    >
      Sub link 3-1
    </NavList.Item>
  2. NextJSLikeLink: This one requires more work because the NavList.Item is nested one layer deep, but it's still predictable. source

    <NextJSLikeLink href="/2">
      <NavList.Item aria-current={window.location.pathname === '/2'}>Link 2</NavList.Item>
    </NextJSLikeLink>
  3. CustomNavLink: 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 the aria-current is present at the site of usage like the second link here:

    <NavList.SubNav>
     <CustomNavLink href="/4-1">
       Sub link 4-1, automatic doesn't work
     </CustomNavLink>
     <CustomNavLink href="/4-2" aria-current={pathname === '/4-1'}>
       {/*                      ↑ ask user to pass it on a direct child        */}
       Sub link 4-2, needs explicit prop to work
     </CustomNavLink>
    </NavList.SubNav>

    It would be even better if we can detect this in dev environments and throw a warning linking to this guidance. source

@changeset-bot
Copy link

changeset-bot bot commented May 17, 2022

⚠️ No Changeset found

Latest commit: d05d4d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@siddharthkp siddharthkp added the skip changeset This change does not need a changelog label May 17, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 65.92 KB (0%)
dist/browser.umd.js 66.2 KB (0%)

@siddharthkp siddharthkp marked this pull request as ready for review May 17, 2022 10:34
@siddharthkp siddharthkp requested review from a team and jfuchs May 17, 2022 10:34
@siddharthkp siddharthkp self-assigned this May 17, 2022
@siddharthkp siddharthkp requested review from colebemis and removed request for jfuchs May 17, 2022 10:35
@siddharthkp siddharthkp temporarily deployed to github-pages May 17, 2022 10:54 Inactive
@siddharthkp siddharthkp mentioned this pull request May 17, 2022
6 tasks
@siddharthkp siddharthkp temporarily deployed to github-pages May 17, 2022 13:45 Inactive
Base automatically changed from navlist-props to main May 19, 2022 21:19
@joshblack joshblack deleted the navlist-props-nested branch January 19, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants