-
Notifications
You must be signed in to change notification settings - Fork 1
Fix popover focus-management gaps and add active-descendant support #40
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
Open
gohabereg
wants to merge
21
commits into
main
Choose a base branch
from
feature/popover-a11y
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
fad5e24
Add Playwright e2e scaffold for ui-kit popover
gohabereg c0d3478
Expose popover items and containers to assistive technologies
gohabereg b7768a0
Move real focus while navigating the popover with the keyboard
gohabereg 858ecbb
Name the back button and the search input
gohabereg 816d018
Announce dynamic popover state changes
gohabereg 555e4b5
Complete the semantics of the remaining popover parts
gohabereg 5a95593
Allow overriding item semantics and bump versions
gohabereg da07de9
Keep the popover appearance and the text selection intact
gohabereg 91eeba0
Close remaining keyboard traps and bump to a major version
gohabereg 363d7d3
Fix roving-tabindex gaps and add an active-descendant hook for AT-sil…
gohabereg 8d6266b
Keep e2e declarations out of the published types
gohabereg af53316
Hide the closed popover from assistive tech and close the keyboard gaps
gohabereg f7228c1
Typecheck the ui-kit sources and test against workspace sources
gohabereg 09afe74
Address the popover a11y review feedback
gohabereg 764f2df
Resolve custom media queries in every popover stylesheet
gohabereg 6f73521
Explain when Flipper should move the focus to its items
gohabereg ecdaf80
Navigate the inline toolbar horizontally and treat html controls as i…
gohabereg f4f7bb7
Close the remaining focus management gaps
gohabereg 04a6f03
Keep item states and names in line with what the items are
gohabereg 1ca4a82
Run the ui-kit e2e suite on CI
gohabereg ab4e71a
Keep separators out of the focus order without making them focusable
gohabereg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,7 @@ node_modules/ | |
|
|
||
| # IDE files | ||
| .idea/ | ||
|
|
||
| # e2e artifacts | ||
| test-results/ | ||
| playwright-report/ | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>UI Kit e2e — confirmation toggle</title> | ||
| </head> | ||
| <body> | ||
| <div style="position: relative; width: 500px; padding: 12px;"> | ||
| <button id="before">Before</button> | ||
| <div style="position: relative;"> | ||
| <button id="trigger">Open menu</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import { PopoverDesktop } from '/src/index.ts'; | ||
|
|
||
| const icon = '<svg width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6"/></svg>'; | ||
|
|
||
| window.__activated = []; | ||
|
|
||
| /** | ||
| * Records item activation so tests can assert it without relying on visuals | ||
| * @param {string} name - name of the activated item | ||
| */ | ||
| const activate = (name) => () => window.__activated.push(name); | ||
|
|
||
| const popover = new PopoverDesktop({ | ||
| scopeElement: document.body, | ||
| items: [ | ||
| { | ||
| icon, | ||
| title: 'Pin', | ||
| name: 'pin', | ||
| /** A toggle that asks for a confirmation too: clicking both toggles it and swaps it into confirmation mode */ | ||
| toggle: true, | ||
| onActivate: activate('pin'), | ||
| confirmation: { | ||
| icon, | ||
| title: 'Sure?', | ||
| name: 'pin-confirm', | ||
| onActivate: activate('pin-confirm'), | ||
| }, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| document.getElementById('trigger').insertAdjacentElement('afterend', popover.getElement()); | ||
| document.getElementById('trigger').addEventListener('click', () => popover.show()); | ||
|
|
||
| window.popover = popover; | ||
| document.body.dataset.ready = 'true'; | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>UI Kit e2e — html items</title> | ||
| </head> | ||
| <body> | ||
| <div style="position: relative; width: 500px; padding: 12px;"> | ||
| <button id="before">Before</button> | ||
| <div style="position: relative;"> | ||
| <button id="trigger">Open menu</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import { PopoverDesktop, PopoverEvent, PopoverItemType } from '/src/index.ts'; | ||
|
|
||
| const icon = '<svg width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6"/></svg>'; | ||
|
|
||
| window.__activated = []; | ||
|
|
||
| /** | ||
| * Records item activation so tests can assert it without relying on visuals | ||
| * @param {string} name - name of the activated item | ||
| */ | ||
| const activate = (name) => () => window.__activated.push(name); | ||
|
|
||
| /** | ||
| * Html item that opens a submenu, as a legacy inline tool with actions does in Editor.js | ||
| */ | ||
| const moreElement = document.createElement('div'); | ||
|
|
||
| moreElement.innerHTML = '<button>More</button>'; | ||
|
|
||
| /** | ||
| * Html item holding the native controls a custom tune may render: a checkbox, a select, a link | ||
| */ | ||
| const controlsElement = document.createElement('div'); | ||
|
|
||
| controlsElement.innerHTML = '<label><input type="checkbox"> Check</label>' | ||
| + '<select aria-label="Pick"><option>One</option></select>' | ||
| + '<a href="#link">Link</a>'; | ||
|
|
||
| window.__activeDescendants = []; | ||
|
|
||
| const popover = new PopoverDesktop({ | ||
| scopeElement: document.body, | ||
| items: [ | ||
| { | ||
| icon, | ||
| title: 'Plain', | ||
| name: 'plain', | ||
| onActivate: activate('plain'), | ||
| }, | ||
| { | ||
| type: PopoverItemType.Html, | ||
| element: moreElement, | ||
| name: 'html-parent', | ||
| children: { | ||
| items: [ | ||
| { | ||
| icon, | ||
| title: 'Child A', | ||
| name: 'child-a', | ||
| onActivate: activate('child-a'), | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| type: PopoverItemType.Html, | ||
| element: controlsElement, | ||
| name: 'html-controls', | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| /** Every id the popover reports the highlighted item with, in order */ | ||
| popover.on(PopoverEvent.ActiveDescendantChanged, id => window.__activeDescendants.push(id)); | ||
|
|
||
| document.getElementById('trigger').insertAdjacentElement('afterend', popover.getElement()); | ||
| document.getElementById('trigger').addEventListener('click', () => popover.show()); | ||
|
|
||
| window.popover = popover; | ||
| document.body.dataset.ready = 'true'; | ||
| </script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain when it’s expected to be set as “false” and “true”. Alternatively, remove this option and make it focusable by default.