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

feat(useFocusZone): update active-descendant on mousemove #1308

Merged
merged 13 commits into from
Jun 24, 2021

Conversation

dgreif
Copy link
Member

@dgreif dgreif commented Jun 15, 2021

This introduces some additional refinements to active-descendant and its use in ActionList.

  • Active descendant will now move when there is a mousemove event over any "focusable" item within the container. Practically speaking, this means mousing over items in an ActionList will cause the active descendant to move with the mouse. This is more in-line with MacOS system menus, which move focus with mouse and/or keyboard
  • Active descendants will now directly receive an attribute which can be used for styling them (rather than needing to apply/remove a class in the update callback). It will be in the form of data-is-active-descendant="activated-directly" or data-is-active-descendant="activated-indirectly". The presence of data-is-active-descendant tells you that the item is active, and activated-* gives insight into how it was activated. The only way to activate "directly" right now is to use the up/down arrows or directly focus an item (by clicking on it). All other interactions (mouseover, adding/removing elements, initial zone creation) are considered actions that moved active descendant "indirectly". Using these additional details, we can now render ActionList items differently depending on how users interacted with the list.
  • focusZone will now add an additional data-has-active-descendant to the container. This is helpful because the aria-activedescendant attribute is put on the control element.
  • Combining the new data-has-active-descendant and :focus-within, we are able to detect at the list level if there is an active or focused item within the list. If so, we want to ignore :hover styles to avoid confusion about which element will receive events if you press Enter.
  • Updated SelectPanel to have a more proper active descendant setup. The ActionList is now the container, and the input used for controlling the list is outside of the container. This required the addition of forwaredRef for the List component.

Closes https://github.com/github/primer/issues/199

Screenshots

SelectPanel (Active Descendant)

CleanShot 2021-06-22 at 11 37 02

ActionMenu (Focus)

CleanShot 2021-06-22 at 11 39 12

Merge checklist

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

@changeset-bot
Copy link

changeset-bot bot commented Jun 15, 2021

🦋 Changeset detected

Latest commit: 2f3567d

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@vercel
Copy link

vercel bot commented Jun 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/9KA5iYMtZmnZ9ZWbQBqsrFAv9ZFg
✅ Preview: https://primer-components-git-active-descendant-refinements-primer.vercel.app

@dgreif dgreif force-pushed the active-descendant-refinements branch from fc7dfd8 to 4db22de Compare June 15, 2021 15:56
@vercel vercel bot temporarily deployed to Preview June 15, 2021 15:56 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from 4db22de to c59b206 Compare June 15, 2021 19:39
@vercel vercel bot temporarily deployed to Preview June 15, 2021 19:39 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from c59b206 to f4ff6d3 Compare June 17, 2021 00:37
@vercel vercel bot temporarily deployed to Preview June 17, 2021 00:37 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from f4ff6d3 to b92ac61 Compare June 17, 2021 23:24
@vercel vercel bot temporarily deployed to Preview June 17, 2021 23:24 Inactive
@vercel vercel bot temporarily deployed to Preview June 17, 2021 23:34 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from 23313d6 to 6304616 Compare June 18, 2021 04:15
@vercel vercel bot temporarily deployed to Preview June 18, 2021 04:15 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from 6304616 to ce5712c Compare June 18, 2021 05:00
@vercel vercel bot temporarily deployed to Preview June 18, 2021 05:00 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from ce5712c to 967f51d Compare June 18, 2021 14:41
@vercel vercel bot temporarily deployed to Preview June 18, 2021 14:41 Inactive
@dgreif dgreif force-pushed the active-descendant-refinements branch from 967f51d to b98d2da Compare June 22, 2021 17:53
@vercel vercel bot temporarily deployed to Preview June 22, 2021 17:53 Inactive
@vercel vercel bot temporarily deployed to Preview June 22, 2021 18:50 Inactive
@dgreif dgreif requested review from smockle and colebemis June 22, 2021 18:50
@dgreif dgreif marked this pull request as ready for review June 22, 2021 18:50
@vercel vercel bot temporarily deployed to Preview June 22, 2021 19:01 Inactive
@vercel vercel bot temporarily deployed to Preview June 22, 2021 19:15 Inactive
@vercel vercel bot temporarily deployed to Preview June 22, 2021 19:18 Inactive
src/ActionList/Item.tsx Outdated Show resolved Hide resolved
src/ActionList/Item.tsx Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview June 22, 2021 19:30 Inactive
src/ActionList/Item.tsx Outdated Show resolved Hide resolved
Co-authored-by: Vinicius Depizzol <[email protected]>
@vercel vercel bot temporarily deployed to Preview June 22, 2021 22:40 Inactive
src/behaviors/focusZone.ts Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview June 23, 2021 23:34 Inactive
@vercel vercel bot temporarily deployed to Preview June 24, 2021 19:42 Inactive
@vercel vercel bot temporarily deployed to Preview June 24, 2021 19:46 Inactive
@dgreif dgreif enabled auto-merge (squash) June 24, 2021 19:49
@vercel vercel bot temporarily deployed to Preview June 24, 2021 19:49 Inactive
@dgreif dgreif merged commit a8f3ca6 into main Jun 24, 2021
@dgreif dgreif deleted the active-descendant-refinements branch June 24, 2021 19:52
@github-actions github-actions bot mentioned this pull request Jun 24, 2021
colebemis added a commit that referenced this pull request Jul 19, 2021
* add utility props to Box

* update box docs

* export box props

* update snapshots

* Create green-worms-nail.md

* AvatarStack story in storybook

* Update .changeset/green-worms-nail.md

Co-authored-by: Cole Bemis <[email protected]>

* Update docs/content/Box.md

Co-authored-by: Cole Bemis <[email protected]>

* Remove duplicate border system prop definitions

* Remove duplicate grid system props definitions

* Update FlexProps definition

* Remove duplicate position system prop definitions

* Update Box documentation

* Update BoxProps

* Update Box docs

* Update Box props

* fix: Type 'DropdownButton' as 'button' (#1318)

* fix: Type 'DropdownButton' as 'button'

* chore: Update snapshots

* chore: Set test directory via config rather than flag (#1319)

* feat(useFocusZone): update active-descendant on mousemove (#1308)

* fix: Split `<Item>` labels (#1320)

* fix: Separate 'Item' content into 'label' and 'description'

* fix: Only add 'aria-describedby' when 'description' exists

* fix: Memoize 'id' so 'Item's and labels match

* fix: Don’t rely on 'id' which is possibly not globally-unique

* fix: Restore semi-full-width 'Item' dividers, without giving up the semantic nesting.

By “semantic nesting”, I mean that the 'Item' label and description are now siblings, which is preferable to the previous implementation, where the description node was a child of the label node. As a general principle, we should align DOM hierarchies with information hierarchies. An analogy: If I were using a bulleted list to describe a dog, I would not indent its breed as a second-level bullet beneath the bullet for its name, because a dog’s breed is not dependent/derived data from its name. Similarly, description is not dependent/derived from label, and so should not be nested in DOM.

* fix: Reduce styled-components class permutations.

https://www.joshwcomeau.com/css/styled-components/

* feat(Overlay): slide away from anchor based on position (#1322)

* feat(Overlay): slide away from anchor based on position

* fix: handle position changes when re-opening AnchoredOverlay

* refactor: use js animation for slide to fix safari

* fix: Tests were failing with Axe violations

- https://dequeuniversity.com/rules/axe/4.1/aria-dialog-name
- https://dequeuniversity.com/rules/axe/4.2/presentation-role-conflict
- https://www.w3.org/TR/wai-aria-practices-1.1/examples/menu-button/menu-button-links.html

First, 'Overlay's aren’t 'listbox'es, because (when used in 'DropdownMenu' or 'ActionMenu') they contain 'menuitem's, 'menuitemradio's, or 'menuitemcheckbox'es.

Second, 'Overlay's aren’t 'dialog's, because (as demonstrated in the WAI ARIA practices page linked above), 'menu's need not be contained in a 'dialog', and also (as noted in the 'aria-dialog-name' link above), 'dialog's must have an 'aria-label', 'aria-labelledby', or 'title', but neither 'DropdownMenu' nor 'ActionMenu' have any kind of header element that could be used for this.

Third, if 'Overlay's are 'none', they can’t be focusable (as noted in the 'presentation-role-conflict' link above), but one of our hooks (maybe 'FocusTrap', maybe 'FocusZone') was setting 'tabIndex' to '0' (in the test component), because it did not contain a focusable child. This PR adds a focusable button child so the 'none' 'Overlay' container won’t receive 'tabIndex' '0'.

* fix: Resolve lint errors

Co-authored-by: Clay Miller <[email protected]>

* Generate prop documentation (#1323)

* Add new filesystem source

* Add component metadata type

* Create Props component

* Update props table

* Handle empty and error states

* Add required label

* Update required prop styles

* Clean up code comments

* Remove filesystem plugin

* Remove extra markdown file

* Add component comment

Co-authored-by: Clay Miller <[email protected]>

* Improve treeshaking by setting package.json sideEffects (#1332)

* fix: mark sideEffects free

* fix: update sideEffects delcaration in package.json to improve treeshaking

* fix: update sideEffects delcaration in package.json to improve treeshaking

* fix: BaseStyles doesnt use sideeffects

* chore: add changeset

* Update Box documentation

* Update BoxProps

* Update Box docs

* Update Box props

* Remove AvatarStack story

* Update .changeset/green-worms-nail.md

Co-authored-by: Cole Bemis <[email protected]>
Co-authored-by: Clay Miller <[email protected]>
Co-authored-by: Dusty Greif <[email protected]>
Co-authored-by: Matthew Costabile <[email protected]>
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.

3 participants