-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix: react-popover compatibility with screen reader #28172
base: master
Are you sure you want to change the base?
fix: react-popover compatibility with screen reader #28172
Conversation
📊 Bundle size reportUnchanged fixtures
|
@@ -45,10 +46,13 @@ export const usePopoverSurface_unstable = ( | |||
root: 'div', | |||
}, | |||
root: getNativeElementProps('div', { | |||
id, | |||
'aria-labelledby': id, |
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.
ah sorry, I think I forgot to mention -- I think the id
+ aria-labelledby
should go in the examples, rather than in the base component. The reason is that I think having a popover be labelled by all its content is too opinionated as a default. It works well for small popovers like our examples, but not for longer popovers (which should probably be labelled just by the title).
We'll add docs about how to properly label, but for now I think this bit should be in the examples
change/@fluentui-react-popover-54e46725-d634-43de-961b-a174b511fa9a.json
Outdated
Show resolved
Hide resolved
packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts
Outdated
Show resolved
Hide resolved
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
FluentProviderWithTheme | mount | 81 | 86 | 10 | Possible regression |
All results
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 588 | 580 | 5000 | |
Button | mount | 303 | 296 | 5000 | |
Field | mount | 1056 | 1025 | 5000 | |
FluentProvider | mount | 640 | 654 | 5000 | |
FluentProviderWithTheme | mount | 81 | 86 | 10 | Possible regression |
FluentProviderWithTheme | virtual-rerender | 74 | 74 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 76 | 77 | 10 | |
InfoButton | mount | 17 | 13 | 5000 | |
MakeStyles | mount | 863 | 862 | 50000 | |
Persona | mount | 1592 | 1605 | 5000 | |
SpinButton | mount | 1238 | 1272 | 5000 |
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 517b807cd97ee89a470ac5e9dec48a6f42b69532 (build) |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 061fc3e:
|
🕵 fluentuiv9 No visual regressions between this PR and main |
@@ -49,6 +49,7 @@ export const usePopoverSurface_unstable = ( | |||
role: trapFocus ? 'dialog' : 'group', | |||
'aria-modal': trapFocus ? true : undefined, | |||
...modalAttributes, | |||
tabIndex: '-1', |
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.
in cases where popovers don't contain focusable elemnts, wouldn't users just be able to use inline
?
There's nothing in this component that will actually focus this element if it's open. Unless the conclusion behind this PR is that we should be doing that?
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.
@smhigley probably has more insight to share
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.
@ling1726 the popover does actually get focus when tabIndex="-1"
is present -- my assumption was that tabster was doing that 😅
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.
PopoverSurface gets focus when tabIndex=-1
because of this useEffect
fluentui/packages/react-components/react-popover/src/components/Popover/usePopover.ts
Line 129 in 517b807
const firstFocusable = isNaN(containerTabIndex) |
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.
When the popover was built, we never expected the focusing effect to work when users don't put focusable elements inside popovers. Our guidance has always been to treat popovers as dialogs when this happens use trapFocus
in that case.
@smhigley if popovers have no focusable content, would inline
be enough? if we result to focusing the entire popover by default always, I don't see a reason to use inline
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
…1fa9a.json Co-authored-by: Esteban Munoz Facusse <esteban.230@hotmail.com>
21b5773
to
061fc3e
Compare
Allows the popover created by react-popover to be read by screen readers despite having no focusable content.