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

Make FocusTrapZone useful for focusing the first item in a virtual list #14606

Merged
merged 8 commits into from
Oct 29, 2020

Conversation

ThomasMichon
Copy link
Member

Description of changes

Made some minor updates to FocusTrapZone so it can be leveraged to implement a common accessibility requirement: "Select the first row in the List". Unlike previous attempts at solving this issue, such as using initialFocusedIndex on DetailsList, this approach allows a host app to specify when and how it wants to focus an element, simply by providing the correct selector for firstFocusableElement on a FocusTrapZone and calling .focus() on its component ref after the content loads. The ideal selector to use is [data-selection-index="0"], which is the first content row according to the SelectionZone. This works well with both DetailsList and TilesList without requiring either component to implement something custom.

Focus areas to test

Example pages for TilesList and DetailsList have been updated to include the behavior and showcase its non-invasive impact.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 19, 2020

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 78d0f87:

Sandbox Source
Fluent UI Button Configuration
codesandbox-react-template Configuration

@size-auditor
Copy link

size-auditor bot commented Aug 19, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react office-ui-fabric-react-FocusTrapZone 14.445 kB 14.686 kB ExceedsBaseline     241 bytes
office-ui-fabric-react office-ui-fabric-react-Callout 83.868 kB 84.109 kB ExceedsBaseline     241 bytes
office-ui-fabric-react office-ui-fabric-react-HoverCard 96.605 kB 96.845 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-Panel 193.574 kB 193.814 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-Dialog 203.267 kB 203.507 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-DatePicker 204.403 kB 204.643 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-Dropdown 225.32 kB 225.56 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-Coachmark 92.468 kB 92.708 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-Modal 93.683 kB 93.923 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-TeachingBubble 198.288 kB 198.528 kB ExceedsBaseline     240 bytes
office-ui-fabric-react office-ui-fabric-react-ComboBox 238.115 kB 238.325 kB ExceedsBaseline     210 bytes
office-ui-fabric-react office-ui-fabric-react-ContextualMenu 151.248 kB 151.381 kB ExceedsBaseline     133 bytes
office-ui-fabric-react office-ui-fabric-react-OverflowSet 50.458 kB 50.591 kB ExceedsBaseline     133 bytes
office-ui-fabric-react office-ui-fabric-react-Keytip 78.56 kB 78.693 kB ExceedsBaseline     133 bytes
office-ui-fabric-react office-ui-fabric-react-ButtonGrid 173.914 kB 174.046 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Nav 181.415 kB 181.547 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-DocumentCard 208.098 kB 208.23 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Tooltip 83.853 kB 83.985 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Persona 111.685 kB 111.817 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-PersonaCoin 111.685 kB 111.817 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Grid 173.914 kB 174.046 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Pickers 275.775 kB 275.907 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Pivot 179.113 kB 179.245 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-PositioningContainer 71.044 kB 71.176 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-CommandBar 194.532 kB 194.664 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-SwatchColorPicker 184.296 kB 184.428 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Utilities 69.69 kB 69.822 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-SearchBox 180.207 kB 180.339 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Breadcrumb 192.151 kB 192.283 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-MessageBar 182.313 kB 182.445 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Button 186.846 kB 186.978 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Keytips 102.049 kB 102.181 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-KeytipLayer 98.938 kB 99.07 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-Facepile 202.871 kB 203.003 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-SpinButton 186.263 kB 186.395 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-FloatingPicker 232.575 kB 232.707 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-SelectedItemsList 222.024 kB 222.156 kB ExceedsBaseline     132 bytes
office-ui-fabric-react office-ui-fabric-react-GroupedList 121.731 kB 121.809 kB ExceedsBaseline     78 bytes
office-ui-fabric-react office-ui-fabric-react-List 36.799 kB 36.877 kB ExceedsBaseline     78 bytes
office-ui-fabric-react office-ui-fabric-react-DetailsList 215.308 kB 215.386 kB ExceedsBaseline     78 bytes
office-ui-fabric-react office-ui-fabric-react-ShimmeredDetailsList 225.716 kB 225.794 kB ExceedsBaseline     78 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: 9bcc6172721b53c64d04556b2312b26e8c6e0278 (build)

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Aug 19, 2020

Perf Analysis

No significant results to display.

All results

Scenario Render type 7.0 Ticks PR Ticks Iterations Status
BaseButton mount 997 993 5000
Breadcrumb mount 45294 43795 5000
Checkbox mount 1750 1724 5000
CheckboxBase mount 1447 1486 5000
ChoiceGroup mount 5521 5514 5000
ComboBox mount 1001 978 1000
CommandBar mount 8475 8618 1000
ContextualMenu mount 15330 14623 1000
DefaultButton mount 1247 1242 5000
DetailsRow mount 3955 3855 5000
DetailsRowFast mount 3854 3888 5000
DetailsRowNoStyles mount 3732 3759 5000
Dialog mount 1633 1647 1000
DocumentCardTitle mount 1877 1870 1000
Dropdown mount 2798 2817 5000
FocusTrapZone mount 1824 1815 5000
FocusZone mount 1893 1922 5000
IconButton mount 1946 1929 5000
Label mount 352 363 5000
Layer mount 2166 2106 5000
Link mount 481 481 5000
MenuButton mount 1647 1608 5000
MessageBar mount 2147 2200 5000
Nav mount 3548 3563 1000
OverflowSet mount 1529 1546 5000
Panel mount 1528 1576 1000
Persona mount 912 901 1000
Pivot mount 1512 1541 1000
PrimaryButton mount 1430 1415 5000
Rating mount 8434 8576 5000
SearchBox mount 1355 1387 5000
Shimmer mount 2835 2815 5000
Slider mount 1596 1571 5000
SpinButton mount 5399 5421 5000
Spinner mount 437 411 5000
SplitButton mount 3396 3392 5000
Stack mount 531 537 5000
StackWithIntrinsicChildren mount 1739 1701 5000
StackWithTextChildren mount 5184 5050 5000
SwatchColorPicker mount 10839 10944 5000
TagPicker mount 2930 2912 5000
TeachingBubble mount 51923 51916 5000
Text mount 437 451 5000
TextField mount 1431 1485 5000
Toggle mount 896 903 5000
button mount 120 114 5000

Copy link
Member

@khmakoto khmakoto left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this fix, but due to work we're currently doing to prepare master for our version 8 beta release, we're asking contributors to either wait a couple weeks to submit fixes (if it's not urgent) or submit to the new 7.0 branch (if it's urgent). See #15222 for more details.

@ThomasMichon ThomasMichon force-pushed the details-list-focus branch 2 times, most recently from 9d1b183 to eb7e7ec Compare October 7, 2020 04:22
Copy link
Member

@dzearing dzearing left a comment

Choose a reason for hiding this comment

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

see 2 comments

Copy link
Member

@khmakoto khmakoto left a comment

Choose a reason for hiding this comment

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

I agree on adding a test but approved for now.

@khmakoto
Copy link
Member

Now that we're publishing beta versions of 8.0 please also port this to the master branch once it merges.

@msft-github-bot
Copy link
Contributor

Hello @ThomasMichon!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msft-github-bot) and give me an instruction to get started! Learn more here.

@ecraig12345
Copy link
Member

Looks like some API updates are missing

@msft-github-bot msft-github-bot merged commit 578e760 into microsoft:7.0 Oct 29, 2020
@msft-github-bot
Copy link
Contributor

🎉@uifabric/utilities@v7.33.2 has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉office-ui-fabric-react@v7.149.0 has been released which incorporates this pull request.:tada:

Handy links:

khmakoto added a commit to khmakoto/fluentui that referenced this pull request Oct 29, 2021
khmakoto added a commit that referenced this pull request Nov 12, 2021
…st (#20413)

* Porting #14606 to v8.

* Change files

* Removing focus.ts changes.

* Delete @fluentui-utilities-a66b0f6c-334f-4416-b397-75393f9d22a7.json
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
…st (microsoft#20413)

* Porting microsoft#14606 to v8.

* Change files

* Removing focus.ts changes.

* Delete @fluentui-utilities-a66b0f6c-334f-4416-b397-75393f9d22a7.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants