Skip to content

[UnderlineNav2]: Introduce disclosure widget pattern - #2466

Merged
broccolinisoup merged 7 commits into
mainfrom
introduce-disclosure-pattern
Oct 26, 2022
Merged

[UnderlineNav2]: Introduce disclosure widget pattern#2466
broccolinisoup merged 7 commits into
mainfrom
introduce-disclosure-pattern

Conversation

@broccolinisoup

@broccolinisoupbroccolinisoup commented Oct 21, 2022

Copy link
Copy Markdown
Member

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

changeset-botBot commented Oct 21, 2022

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactMinor

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
broccolinisoupforce-pushed the introduce-disclosure-pattern branch 2 times, most recently from 00b7607 to 177ab6bCompareOctober 21, 2022 20:36
@broccolinisoup
broccolinisoup temporarily deployed to github-pages October 21, 2022 20:43 Inactive
@broccolinisoup

broccolinisoup commented Oct 21, 2022

Copy link
Copy Markdown
MemberAuthor

@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

github-actionsBot commented Oct 23, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js78.14 KB (0%)
dist/browser.umd.js78.79 KB (0%)

@broccolinisoup
broccolinisoup temporarily deployed to github-pages October 23, 2022 22:31 Inactive
@broccolinisoup
broccolinisoupforce-pushed the underlineNav-sign-off-remediations branch 2 times, most recently from 611c1a5 to 88e4586CompareOctober 23, 2022 22:53
@broccolinisoup
broccolinisoupforce-pushed the introduce-disclosure-pattern branch from b115613 to 8427af9CompareOctober 23, 2022 22:58
@broccolinisoup
broccolinisoup temporarily deployed to github-pages October 23, 2022 23:04 Inactive
@broccolinisoup
broccolinisoupforce-pushed the introduce-disclosure-pattern branch from 8427af9 to ef2cb54CompareOctober 24, 2022 01:50
@broccolinisoupbroccolinisoup 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
@broccolinisoupbroccolinisoup changed the title [UnderlineNav2]: Introduce disclosure pattern[UnderlineNav2]: Introduce disclosure widget patternOct 24, 2022
@broccolinisoup
broccolinisoup marked this pull request as ready for review October 24, 2022 04:42
Comment threadsrc/UnderlineNav2/styles.ts Outdated
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}`,

@siddharthkpsiddharthkpOct 24, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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!

Comment threadsrc/UnderlineNav2/UnderlineNav.tsx Outdated

@ericwbaileyericwbailey left a comment

Copy link
Copy Markdown
Contributor

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!

Comment threadsrc/UnderlineNav2/UnderlineNav.tsx Outdated

@joshblackjoshblack left a comment

Copy link
Copy Markdown
Member

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 ✨

Comment threadsrc/UnderlineNav2/UnderlineNav.tsx Outdated
@broccolinisoup
broccolinisoupforce-pushed the underlineNav-sign-off-remediations branch 2 times, most recently from 7ac221a to 6c076f1CompareOctober 24, 2022 23:59
Base automatically changed from underlineNav-sign-off-remediations to mainOctober 25, 2022 00:11
@broccolinisoup
broccolinisoupforce-pushed the introduce-disclosure-pattern branch from ef2cb54 to 2b1a8d2CompareOctober 25, 2022 00:15
@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

broccolinisoup commented Oct 25, 2022

Copy link
Copy Markdown
MemberAuthor

@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 💖

@colebemiscolebemis left a comment

Copy link
Copy Markdown
Contributor

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 🚢

broccolinisoupand 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
@broccolinisoupbroccolinisoup removed the skip changeset This change does not need a changelog label Oct 26, 2022
@broccolinisoup
broccolinisoupforce-pushed the introduce-disclosure-pattern branch from 5c48cdc to f1e411eCompareOctober 26, 2022 00:04
@broccolinisoup
broccolinisoup temporarily deployed to github-pages October 26, 2022 00:10 Inactive
@broccolinisoup
broccolinisoup merged commit 9ff856d into mainOct 26, 2022
@broccolinisoup
broccolinisoup deleted the introduce-disclosure-pattern branch October 26, 2022 00:18
@primer-cssprimer-css mentioned this pull request Oct 26, 2022
Sign up for freeto 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.

5 participants

@broccolinisoup@ericwbailey@siddharthkp@joshblack@colebemis