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

fix: close mobile nav on blur of nav list #380

Conversation

SatyamSetia
Copy link
Member

Describe your changes

This PR contains 2 changes as follows -

  1. Solves the issue Keyboard focus going on hidden elements in smaller resolutions #379
  2. Minor refactoring - rename state variables in Layout.tsx and related child components and stories (name changed from showNavMobile to isNavMobileOpen)

Link to issue

Closes #379

Checklist before requesting a review

  • I have performed a self-review of my code.
  • Followed the repository's Contributing Guidelines.
  • I ran the app and tested it locally to verify that it works as expected.
  • I have checked my code with an automatic accessibility tool such as Axe Dev Tools or Wave
    and it shows no errors.

Additional Information (Optional)

Any additional information that you want to give us.

@SatyamSetia
Copy link
Member Author

Hey, @EmmaDawsonDev
Requesting your review on this PR whenever you get time.

Copy link
Member

@EmmaDawsonDev EmmaDawsonDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Satyam,

I'm not sure all the refactoring/name changing was really necessary. In the future it would be better to discuss these possible changes before going ahead and making them. I prefer to keep pull requests small and focused on one thing. The refactoring should be a separate pull request if it's decided that it's a needed change.

With regards to the navigation bug. It now closes as expected when tabbing forwards. However, if you tab to the last item and then choose to shift+tab to go backwards it also triggers the nav to close and this is not the expected behaviour.

}: INavProps) => {
const handleNavBlur = useCallback((event: FocusEvent<HTMLAnchorElement>) => {
const isLastNavItem = /true/i.test(event.target.dataset?.lastNavItem ?? "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what's going on in this line. I've not seen this syntax before. Can you explain what's happening?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a regex shorthand checking if the tested string contains true and returning a boolean. the tested string is either whatever event.target.dataset?.lastNavItem returns or an empty string. a needlessly complex way of doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard focus going on hidden elements in smaller resolutions
3 participants