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

UnderlineNav2: Handle the case when container is too small to render any items #2770

Merged
merged 16 commits into from
Feb 2, 2023

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Jan 12, 2023

Closes #2752

Issue

UnderlineNav v2 was throwing an error when the container is too small to render any items. Although there was no item in the list, it was still trying to swap a menu item with a list item to keep the selected one always visible and it resulted an error.

Solution

We fixed the issue by making sure we only swap items to keep the selected one visible when there is at least 1 element on the list. When the screen is too small to display one list element with the more menu button, we pull all items in the menu.

Caveat

When we display only the menu button, the menu items are not visually accessible. And this is something we are aware of. This is a very edge case as a browser can get that much narrow only when the dev tool is open. We will make sure we address this when working on mobile design for UnderlineNav.

Screenshots

Kapture.2023-01-27.at.13.59.46.mp4

Video displays the browser is being resized to a smaller size when the dev tool is open on the right hand side. As the browser gets smaller, the list items are being pulled into an overflow menu and they disappears from the screen. When the browser size is too small to display one list item and the menu button, all items goes into the menu and the overflow menu button's text goes from "More" to "Menu". Then the "Menu" button is clicked to show the items but as there is not enough space, the menu items are visually not accessible. Then the browser is being resized to a larger size, the menu items popping out of the menu and are displayed as list items to confirm the original functionality is working as expected.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2023

🦋 Changeset detected

Latest commit: b0d61f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 89.59 KB (+0.09% 🔺)
dist/browser.umd.js 90.22 KB (+0.09% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 06:38 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 06:40 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 06:40 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages January 12, 2023 06:42 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 06:42 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 06:43 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages January 12, 2023 09:38 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 09:39 Inactive
@broccolinisoup broccolinisoup marked this pull request as ready for review January 12, 2023 20:16
@broccolinisoup broccolinisoup requested review from a team and joshblack January 12, 2023 20:16
@broccolinisoup broccolinisoup temporarily deployed to github-pages January 12, 2023 20:22 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 12, 2023 20:23 Inactive
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

🥳

@danielguillan
Copy link
Contributor

I think that from both design and accessibility perspectives, we might want to avoid horizontal scrolling in this scenario too.

A solution could be be to move all items into a dropdown menu if the visible item + more dropdown don't fit in the available space. The dropdown could be labeled using the provided aria-label.

@broccolinisoup
Copy link
Member Author

I think that from both design and accessibility perspectives, we might want to avoid horizontal scrolling in this scenario too.

A solution could be be to move all items into a dropdown menu if the visible item + more dropdown don't fit in the available space. The dropdown could be labeled using the provided aria-label.

Thanks @danielguillan! I was very unsure about it after discarding the scroll behaviour but I couldn't really think of any other solution while making sure to keep the selected item visible and out of the menu. Your suggestion sounds good! I also wonder how we could indicate the selected item when it is in the dropdown?

@broccolinisoup broccolinisoup temporarily deployed to github-pages January 17, 2023 02:45 — with GitHub Actions Inactive
@broccolinisoup
Copy link
Member Author

broccolinisoup commented Jan 17, 2023

UnderlineNav-too-narrow.mp4

Video displays the browser is being resized to a smaller size. As the browser gets smaller, the list items are being pulled in to an overflow menu and they disappears from the screen. When the browser size is too small to display one list item and the menu button, the last is being pulled into the menu as well and the More Menu button text changes to "Items" from "More"

@danielguillan is this something close to what you were thinking? I also updated the button text to "Items" when we only display the menu btn because "More" didn't make sense to me but it is just trying really, let me know what you think 🙌🏻 I also updated the aria-label accordingly

@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 17, 2023 02:45 Inactive
@broccolinisoup
Copy link
Member Author

@broccolinisoup Good point! Then we could stick with "Menu". What do you think?

Sounds good @danielguillan - I updated it with "Menu". For the visual users, they will see the button with the "Menu" text, for screen reader users, it will be announced ${ariaLabel} Menu

@broccolinisoup broccolinisoup temporarily deployed to github-pages January 27, 2023 04:00 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 27, 2023 04:01 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages January 27, 2023 04:06 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 27, 2023 04:07 Inactive
@broccolinisoup
Copy link
Member Author

Hi @primer/accessibility 👋🏻 Would it be possible to get a review for our work here? This story should be a good one to test. I provided info on the description but please let me know if you would need further details. Thank you 🙌🏻

@broccolinisoup broccolinisoup temporarily deployed to github-pages January 27, 2023 22:39 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 January 27, 2023 22:39 Inactive
@inkblotty
Copy link
Contributor

inkblotty commented Feb 1, 2023

Based on our conversation in Office Hour, this is a usable component. Some of the semantics are a bit overkill, but still accessible.

The visibility problem at 150 px width is a non-issue and does not need to be resolved from an accessibility standpoint.

Link to the recording

@broccolinisoup - If we missed testing something you needed eyes on, please let us know (@github/accessibility-reviewers). We're still getting our process for async Office Hours down 🙇

@broccolinisoup
Copy link
Member Author

Based on our conversation in Office Hour, this is a usable component. Some of the semantics are a bit overkill, but still accessible.

The visibility problem at 150 px width is a non-issue and does not need to be resolved from an accessibility standpoint.

Link to the recording

@broccolinisoup - If we missed testing something you needed eyes on, please let us know (@github/accessibility-reviewers). We're still getting our process for async Office Hours down 🙇

Thank you @inkblotty so much! I just watched the recording and this was my first time submitting an issue to accessibility office hours so there were lots I learnt from this experience and how I can provide a better context and question next time - I do appreciate your patience with me 🙏🏻

I am so sorry that I forgot to provide the storybook link in the description and I could have explain better what exactly I needed to have an accessibility review on. You covered everything I was concerned though - thank you so much. I wasn't too worried about the 150px screen size as I mentioned it on the caveat. Although, we don't officially support this size, for users who somehow happen to end up in this size, I was still curious to understand if having only a menu button would that be good solution in terms of accessibility. Maybe it is a little bit overthinking 🙂 You answered all my questions and thank you so much again 🙇🏻‍♀️

@broccolinisoup broccolinisoup temporarily deployed to github-pages February 1, 2023 23:49 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 February 1, 2023 23:49 Inactive
@inkblotty
Copy link
Contributor

inkblotty commented Feb 2, 2023 via email

@primer primer bot temporarily deployed to github-pages February 2, 2023 00:34 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2770 February 2, 2023 00:35 Inactive
@broccolinisoup broccolinisoup enabled auto-merge (squash) February 2, 2023 00:56
@broccolinisoup broccolinisoup temporarily deployed to github-pages February 2, 2023 01:02 — with GitHub Actions Inactive
@broccolinisoup broccolinisoup merged commit 3bf1b0e into main Feb 2, 2023
@broccolinisoup broccolinisoup deleted the bs/underlineNav-narrow-container branch February 2, 2023 01:06
@primer-css primer-css mentioned this pull request Feb 2, 2023
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.

UnderlineNav throws error when screen resizes to a point where no items can render
5 participants