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]: Introduce disclosure widget pattern #2466

Merged
merged 7 commits into from
Oct 26, 2022

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Oct 21, 2022

Following up the accessibility sign-off review feedback (ref: comment), this PR discarding the ActionMenu and introduces a disclosure widget.

Storybook test link : https://primer-0a924a1192-13348165.drafts.github.io/storybook/iframe.html?args=&id=components-underlinenav--internal-responsive-nav&viewMode=story

The reasons for discarding the ActionMenu are

  1. The ActionMenu is a portal which means it doesn't follow the button element (that toggles the menu) in the DOM hierarchy. Considering aria-controls attribute's poor support, we cannot rely on it therefore, the menu has to follow the button in the DOM order.
  2. Keyboard accessibility on the ActionMenu is not aligning with the disclosure pattern one. I.e focus trap or only arrow key navigation.

What did we introduce? (Disclosure widget pattern)

  • We have a button that toggles a menu.
  • Menu immediately follows the button element in the DOM hierarchy.
  • Button has aria-controls and its value is the id of the menu.
  • Button has aria-expanded attribute and conditionally have true / false value.
  • Navigation items (both list and menu items) are navigable with arrow keys (both horizontal and vertical) and the tab key.
  • Menu doesn't trap the focus.
  • Menu can be closed with clicking outside and ESC.

Screenshots

There shouldn't be any visual differences between the ActionMenu version and the disclosure widget version.

Merge checklist

  • 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 Oct 21, 2022

🦋 Changeset detected

Latest commit: f1e411e

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 Minor

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

@ericwbailey

This comment was marked as outdated.

@broccolinisoup broccolinisoup force-pushed the introduce-disclosure-pattern branch 2 times, most recently from 00b7607 to 177ab6b Compare October 21, 2022 20:36
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 21, 2022 20:43 Inactive
@broccolinisoup
Copy link
Member Author

broccolinisoup commented Oct 21, 2022

@ericwbailey I apologise again for pointing out the wrong demo. Here is the correct one. I updated the description with items that we introduced with the disclosure pattern. Looking forward to hearing your feedback 🙌🏼

Thank you so much again 🙏🏼

@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 78.14 KB (0%)
dist/browser.umd.js 78.79 KB (0%)

@broccolinisoup broccolinisoup temporarily deployed to github-pages October 23, 2022 22:31 Inactive
@broccolinisoup broccolinisoup force-pushed the underlineNav-sign-off-remediations branch 2 times, most recently from 611c1a5 to 88e4586 Compare October 23, 2022 22:53
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 23, 2022 23:04 Inactive
@broccolinisoup broccolinisoup added the skip changeset This change does not need a changelog label Oct 24, 2022
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 24, 2022 01:57 Inactive
@broccolinisoup broccolinisoup changed the title [UnderlineNav2]: Introduce disclosure pattern [UnderlineNav2]: Introduce disclosure widget pattern Oct 24, 2022
@broccolinisoup broccolinisoup marked this pull request as ready for review October 24, 2022 04:42
right: '0',
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24)',
borderRadius: '12px',
backgroundColor: `${theme?.colors.canvas.overlay}`,
Copy link
Member

@siddharthkp siddharthkp Oct 24, 2022

Choose a reason for hiding this comment

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

Do we need to access this from theme instead of the token name?

Suggested change
backgroundColor: `${theme?.colors.canvas.overlay}`,
backgroundColor: 'canvas.overlay'

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I didn't know I can just pass the token name! Thank you 🙌🏼 Is it only for colours as we import only colour primitives currently maybe? I see mix practises around, where can I learn more about this? 👀 or should I just dig in? 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do a clean up to remove the other unnecessary theme args in the next PR!

Copy link
Contributor

@ericwbailey ericwbailey left a comment

Choose a reason for hiding this comment

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

I left a comment about utilizing a UUID for the id, but other than that this sounds great to me in AT. Loving the roving tabindex, too!

src/UnderlineNav2/UnderlineNav.tsx Outdated Show resolved Hide resolved
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.

Looks awesome! Just left a minor comment and wanted to +1 the id suggestion from @ericwbailey on the <ul> for the disclosure.

Awesome work ✨

src/UnderlineNav2/UnderlineNav.tsx Outdated Show resolved Hide resolved
@broccolinisoup broccolinisoup force-pushed the underlineNav-sign-off-remediations branch 2 times, most recently from 7ac221a to 6c076f1 Compare October 24, 2022 23:59
Base automatically changed from underlineNav-sign-off-remediations to main October 25, 2022 00:11
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 25, 2022 00:22 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 25, 2022 01:46 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 25, 2022 02:49 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 25, 2022 08:24 Inactive
@broccolinisoup
Copy link
Member Author

broccolinisoup commented Oct 25, 2022

@colebemis following up our conversation around using ActionList.LinkItem instead of ActionList.Item, I have discovered some interesting things today. I currently have 3 issues with the LinkItem

  • Sometimes, super randomly, the menu items don't get the focus. Please see the screen recording below. I cannot get into the menu with keyboard until 0:29 second! I don't know why they start getting the focus after.
  • Focus gets trap in the menu. The last 5 seconds of the recording is showing this issue.
  • Focus ring colour is different on menu items only on Firefox. (We already chatted about this)

Also please notice my key strokes on the recording 😄 Shoutout to @mperrotti for sharing this app on his DOL talk ✨

ActionList.LinkItem.mp4

When ActionList.Item is given as prop, it becomes semantically the same element as ActionList.LinkItem on the DOM, so I am sticking to the ActionList.Item here for now if that is okay. That said, I am curious to understand why this happens, but also think this might more to do with the ActionList.LinkItem than UnderlineNav. So how would you feel if I investigate this separately?

There is one more commit left to review in this PR. Previous commits and implementation are reviewed and approved by Eric and Josh. Thanks to you all again for reviewing 💖

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Latest commit looks good 👍 Ship it 🚢

broccolinisoup and others added 7 commits October 26, 2022 10:03
Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
…11y remediations) (#2471)

* Display at least two items in the menu

* add changeset
…esent (#2470)

* Add visually hidden heading

* add changeset and a test

* append 'navigation' to the aria-label string
@broccolinisoup broccolinisoup removed the skip changeset This change does not need a changelog label Oct 26, 2022
@broccolinisoup broccolinisoup temporarily deployed to github-pages October 26, 2022 00:10 Inactive
@broccolinisoup broccolinisoup merged commit 9ff856d into main Oct 26, 2022
@broccolinisoup broccolinisoup deleted the introduce-disclosure-pattern branch October 26, 2022 00:18
@primer-css primer-css mentioned this pull request Oct 26, 2022
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.

None yet

5 participants