Skip to content

fix(react-avatar): Fix trapFocus in AvatarGroup's PopoverSurface and PopoverSurface's role override#23823

Merged
sopranopillow merged 3 commits intomicrosoft:masterfrom
sopranopillow:avatargroup-selected
Jul 7, 2022
Merged

fix(react-avatar): Fix trapFocus in AvatarGroup's PopoverSurface and PopoverSurface's role override#23823
sopranopillow merged 3 commits intomicrosoft:masterfrom
sopranopillow:avatargroup-selected

Conversation

@sopranopillow
Copy link
Contributor

Current Behavior

  • When Popover is triggered, focus is not trapped inside its surface. This is due to the way AvatarGroup currently works, Popover is used as a container for AvatarGroupItems. Popover trapsFocus to the first focusable item inside the PopoverSurface, therefore this doesn't work.
  • Since PopoverSurface is used as a container for AvatarGroupItems, its role is overriden and role list is not compatible with aria-modal.

New Behavior

  • An overflowSurface slot is added which will only contain the PopoverSurface. The purpose of this slot is to allow for further customization rather than having an internal wrapper. This slot will have overflowContent which now works correctly with trapFocus.
  • AvatarGroup doesn't override PopoverSurface's role anymore and follows correct aria rules.

Related Issue(s)

Fixes #23822

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 7, 2022

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 c57422c:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 7, 2022

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-avatar
AvatarGroup
136.305 kB
40.671 kB
136.845 kB
40.741 kB
540 B
70 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-alert
Alert
80.9 kB
20.322 kB
react-avatar
Avatar
47.36 kB
13.625 kB
react-avatar
AvatarGroupItem
67.075 kB
18.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.182 kB
52.141 kB
react-components
react-components: FluentProvider & webLightTheme
31.883 kB
10.516 kB
🤖 This report was generated against ea986100088f2572e5311a6b572d0dbcf6327d98

@size-auditor
Copy link

size-auditor bot commented Jul 7, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: ea986100088f2572e5311a6b572d0dbcf6327d98 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 7, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1245 1306 5000
Button mount 841 885 5000
FluentProvider mount 1694 1673 5000
FluentProviderWithTheme mount 533 570 10
FluentProviderWithTheme virtual-rerender 517 507 10
FluentProviderWithTheme virtual-rerender-with-unmount 626 559 10
MakeStyles mount 1847 1838 50000
SpinButton mount 2516 2409 5000

'aria-label': 'Overflow',
children: overflowChildren,
role: 'list',
tabIndex: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

my one comment would be I don't think we need the list to be focusable anymore, since it's now wrapped within the popup surface.

Since it looks like the popover surface is the one that now has overflow: scroll, I think that's the only node that would need to be focusable for keyboard scroll

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise it looks good!

Copy link
Contributor Author

@sopranopillow sopranopillow Jul 7, 2022

Choose a reason for hiding this comment

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

That would bring back the same problem of trapFocus not working correctly since the children of PopoverSurface is what will be focused, not the PopoverSurface. I could add the overflow: scroll to the PopoverContent so that it can be focused and allow the user to scroll. What do you think about that change?

@sopranopillow sopranopillow merged commit 7a1737f into microsoft:master Jul 7, 2022
@sopranopillow sopranopillow deleted the avatargroup-selected branch July 7, 2022 21:07
khmakoto pushed a commit to khmakoto/fluentui that referenced this pull request Jul 13, 2022
…PopoverSurface's role override (microsoft#23823)

* fix: Remove override of role=list in AvatarGroup's PopoverSurface and fix trapFocus when Popover is triggered.

* change files

* updating scroll to be on overflowContent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: AvatarGroup's use of PopoverSurface is overriding role: dialog/complementary

4 participants