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

fix: standalone Listbox updates activedescendant correctly #31415

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

smhigley
Copy link
Contributor

@smhigley smhigley commented May 17, 2024

Related to #31140 and #31235

Essentially this moves the initial activeDescendantController setting logic from useComboboxBaseState to useListbox, so it runs when the listbox is first renders instead of based on the change in open state.

That both makes combobox/dropdown aria-activedescendant logic a bit more straightforward (the attribute is set if the referenced option exists), and also makes a standalone listbox work.

It also moves a couple option lookup functions to the context, so that Listbox can access them (previously the getOptionById logic in onFocus wasn't working when not a standalone widget, since it didn't have access to the parent combobox's option collection).

Previous Behavior

The original issue was that listbox did not set the initial activedescendant. The first fix to that issue did so on focus, but that caused issues when clicking also set focus (and reset the activedescendant, potentially causing scroll & jumping).

New Behavior

There's no reason Listbox should not always have aria-activedescendant set while it's present on the page, so this change moves the initial activedescendant logic from the combobox (which handled it when opened) to the listbox (which handles it when initially rendered).

There is a very subtle difference between the two, since the Listbox is rendered when the Combobox/Dropdown trigger gains focus, but before it is opened. This causes a minor difference in when aria-activedescendant is set, but does not cause any practical drawbacks to screen reader users. Some early ARIA combobox pattern work was based around the idea that aria-activedescendant would always be set, so screen readers already handle logic on whether to read the activedescendant based on aria-expanded.

@fabricteam
Copy link
Collaborator

fabricteam commented May 17, 2024

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-combobox
Combobox (including child components)
100.496 kB
33.156 kB
101.45 kB
33.342 kB
954 B
186 B
react-combobox
Dropdown (including child components)
101.129 kB
33.096 kB
102.088 kB
33.285 kB
959 B
189 B
react-timepicker-compat
TimePicker
103.487 kB
34.632 kB
104.444 kB
34.803 kB
957 B
171 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-accordion
Accordion (including children components)
100.008 kB
30.527 kB
react-avatar
Avatar
49.299 kB
15.837 kB
react-avatar
AvatarGroup
20.107 kB
7.973 kB
react-avatar
AvatarGroupItem
63.316 kB
20.017 kB
react-breadcrumb
@fluentui/react-breadcrumb - package
114.486 kB
31.821 kB
react-button
Button
37.103 kB
10.784 kB
react-button
CompoundButton
43.514 kB
12.074 kB
react-button
MenuButton
41.884 kB
12.132 kB
react-button
SplitButton
49.896 kB
13.724 kB
react-button
ToggleButton
53.03 kB
12.543 kB
react-card
Card - All
101.184 kB
29.049 kB
react-card
Card
94.218 kB
27.333 kB
react-card
CardFooter
14.354 kB
5.795 kB
react-card
CardHeader
16.618 kB
6.555 kB
react-card
CardPreview
14.418 kB
5.931 kB
react-datepicker-compat
DatePicker Compat
223.895 kB
63.417 kB
react-dialog
Dialog (including children components)
99.313 kB
29.997 kB
react-menu
Menu (including children components)
152.023 kB
45.98 kB
react-menu
Menu (including selectable components)
154.709 kB
46.477 kB
react-message-bar
MessageBar (all components)
24.411 kB
9.114 kB
react-popover
Popover
127.766 kB
40.096 kB
react-toast
Toast (including Toaster)
97.868 kB
29.513 kB
🤖 This report was generated against a13cb66f314d5e287c3fa788b6300f36135df19e

@fabricteam
Copy link
Collaborator

fabricteam commented May 17, 2024

Perf Analysis (@fluentui/react-components)

Scenario Render type Master Ticks PR Ticks Iterations Status
FluentProviderWithTheme virtual-rerender 36 35 10 Possible regression
FluentProviderWithTheme virtual-rerender-with-unmount 74 71 10 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 632 626 5000
Button mount 303 299 5000
Field mount 1155 1137 5000
FluentProvider mount 697 726 5000
FluentProviderWithTheme mount 84 80 10
FluentProviderWithTheme virtual-rerender 36 35 10 Possible regression
FluentProviderWithTheme virtual-rerender-with-unmount 74 71 10 Possible regression
MakeStyles mount 851 859 50000
Persona mount 1748 1767 5000
SpinButton mount 1413 1421 5000
SwatchPicker mount 1572 1548 5000

@@ -0,0 +1,7 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

🕵 fluentuiv9 Open the Visual Regressions report to inspect the affected screenshots

Avatar Converged 1 screenshots
Image Name Diff(in Pixels) Image Type
Avatar Converged.badgeMask.normal.chromium.png 6 Changed
Card Converged 1 screenshots
Image Name Diff(in Pixels) Image Type
Card Converged.appearance - High Contrast.normal.chromium.png 0 Removed
SwatchPicker Converged 1 screenshots
Image Name Diff(in Pixels) Image Type
SwatchPicker Converged.Shape.default.chromium.png 0 Added

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.

None yet

4 participants