fix(FocusZone): should reset tabindex when focus is outside the zone with prop shouldResetActiveElementWhenTabFromZone#24463
Conversation
|
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 aa94848:
|
Asset size changes
Baseline commit: 625f79c61c8a496a31d19c615a0b8e0d9a72e55b (build) |
📊 Bundle size report🤖 This report was generated against 625f79c61c8a496a31d19c615a0b8e0d9a72e55b |
Perf Analysis (
|
| Scenario | Current PR Ticks | Baseline Ticks | Ratio |
|---|---|---|---|
| ToolbarMinimalPerf.default | 771 | 668 | 1.15:1 |
| AttachmentMinimalPerf.default | 128 | 117 | 1.09:1 |
| PortalMinimalPerf.default | 143 | 133 | 1.08:1 |
| ButtonSlotsPerf.default | 476 | 445 | 1.07:1 |
| SegmentMinimalPerf.default | 291 | 275 | 1.06:1 |
| RadioGroupMinimalPerf.default | 371 | 352 | 1.05:1 |
| BoxMinimalPerf.default | 275 | 265 | 1.04:1 |
| DividerMinimalPerf.default | 292 | 282 | 1.04:1 |
| ListMinimalPerf.default | 419 | 404 | 1.04:1 |
| CustomToolbarPrototype.default | 2441 | 2350 | 1.04:1 |
| AnimationMinimalPerf.default | 445 | 433 | 1.03:1 |
| DialogMinimalPerf.default | 648 | 628 | 1.03:1 |
| DropdownManyItemsPerf.default | 565 | 550 | 1.03:1 |
| FormMinimalPerf.default | 319 | 311 | 1.03:1 |
| HeaderMinimalPerf.default | 297 | 288 | 1.03:1 |
| TextMinimalPerf.default | 283 | 276 | 1.03:1 |
| TextAreaMinimalPerf.default | 389 | 378 | 1.03:1 |
| CardMinimalPerf.default | 438 | 429 | 1.02:1 |
| ChatDuplicateMessagesPerf.default | 241 | 236 | 1.02:1 |
| ChatWithPopoverPerf.default | 315 | 308 | 1.02:1 |
| GridMinimalPerf.default | 277 | 272 | 1.02:1 |
| InputMinimalPerf.default | 1069 | 1047 | 1.02:1 |
| LayoutMinimalPerf.default | 292 | 287 | 1.02:1 |
| MenuMinimalPerf.default | 708 | 695 | 1.02:1 |
| MenuButtonMinimalPerf.default | 1429 | 1398 | 1.02:1 |
| ButtonOverridesMissPerf.default | 1260 | 1249 | 1.01:1 |
| CarouselMinimalPerf.default | 384 | 382 | 1.01:1 |
| ChatMinimalPerf.default | 603 | 598 | 1.01:1 |
| EmbedMinimalPerf.default | 3429 | 3383 | 1.01:1 |
| ItemLayoutMinimalPerf.default | 998 | 985 | 1.01:1 |
| LabelMinimalPerf.default | 319 | 315 | 1.01:1 |
| ListCommonPerf.default | 518 | 512 | 1.01:1 |
| ListNestedPerf.default | 454 | 451 | 1.01:1 |
| ListWith60ListItems.default | 519 | 512 | 1.01:1 |
| LoaderMinimalPerf.default | 567 | 562 | 1.01:1 |
| RosterPerf.default | 1774 | 1765 | 1.01:1 |
| SkeletonMinimalPerf.default | 283 | 279 | 1.01:1 |
| StatusMinimalPerf.default | 563 | 559 | 1.01:1 |
| IconMinimalPerf.default | 533 | 527 | 1.01:1 |
| CheckboxMinimalPerf.default | 2229 | 2226 | 1:1 |
| DropdownMinimalPerf.default | 2629 | 2635 | 1:1 |
| HeaderSlotsPerf.default | 632 | 630 | 1:1 |
| ProviderMinimalPerf.default | 331 | 330 | 1:1 |
| ReactionMinimalPerf.default | 303 | 303 | 1:1 |
| RefMinimalPerf.default | 182 | 182 | 1:1 |
| SliderMinimalPerf.default | 1409 | 1409 | 1:1 |
| SplitButtonMinimalPerf.default | 3654 | 3654 | 1:1 |
| TableManyItemsPerf.default | 1550 | 1553 | 1:1 |
| VideoMinimalPerf.default | 594 | 592 | 1:1 |
| ImageMinimalPerf.default | 312 | 316 | 0.99:1 |
| PopupMinimalPerf.default | 520 | 525 | 0.99:1 |
| TableMinimalPerf.default | 326 | 328 | 0.99:1 |
| TreeMinimalPerf.default | 660 | 666 | 0.99:1 |
| AttachmentSlotsPerf.default | 920 | 939 | 0.98:1 |
| DatepickerMinimalPerf.default | 4740 | 4828 | 0.98:1 |
| AlertMinimalPerf.default | 212 | 218 | 0.97:1 |
| ButtonMinimalPerf.default | 126 | 130 | 0.97:1 |
| ProviderMergeThemesPerf.default | 1028 | 1056 | 0.97:1 |
| TooltipMinimalPerf.default | 1894 | 1957 | 0.97:1 |
| AvatarMinimalPerf.default | 150 | 156 | 0.96:1 |
| AccordionMinimalPerf.default | 113 | 120 | 0.94:1 |
| TreeWith60ListItems.default | 129 | 138 | 0.93:1 |
| FlexMinimalPerf.default | 213 | 233 | 0.91:1 |
shouldResetActiveElementWhenTabFromZone
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| expect(buttonC.tabIndex).toBe(0); | ||
| }); | ||
|
|
||
| it('Update tabIndex when FocusZone is changed before focused', () => { |
There was a problem hiding this comment.
there is no sense testing this in JSDOM, this should by tested with cypress directly in the browser
There was a problem hiding this comment.
why no sense when the test works as expected? I was initially thinking cypress would be more readable; but eventually did this test as we have all FTZ test here.
There was a problem hiding this comment.
Honestly I think most of our tests should be run on browser, they are quite uncomplicated and give us the 'closest' realistic scenario.
Especially for something like focus, it's really browser specific. It's not a blocker but setting up some FZ tests for the browser would be nice
ling1726
left a comment
There was a problem hiding this comment.
Honestly this seems like a userland problem if we could expose an imperative ref like we do with popper
const fzRef = React.useRef<FocusZomeImperativeRef>();
fzRef.updateTabIndexes();...but that opens a whole other can of worms. I couldn't think of a better solution so here is your approval :)
* master: (63 commits) feat: add helper types to assist DOM element handling (microsoft#24722) applying package updates Textarea/hc bug (microsoft#24701) Fix null ref in use slider (microsoft#24728) Add Field unit tests, and remove snapshot tests (microsoft#24706) Stress Test: add build commands (microsoft#24575) Coachmark - useOffsetHeight should cause re-render on each set state to match v7 functionality (microsoft#24702) Implement screener tests for Field components (microsoft#24684) Update Field types to clean up react-field.api.md (microsoft#24703) fix(Popup): remove rotate(360deg) from PopupContent content styles (microsoft#24432) fix(FocusZone): should reset tabindex when focus is outside the zone with prop `shouldResetActiveElementWhenTabFromZone` (microsoft#24463) Fix greyed out legend key contrast ratio (microsoft#24714) fix: Portal compat should apply `focus-visible` ponyfill (microsoft#24712) Fix artifact error (microsoft#24717) chore(react-dialog): remove localShorthands in favor of griffel shorthands (microsoft#24715) Skip screener checks for draft PRs with exception of appropriately la… (microsoft#24694) fix: Remove provider classname from focus styles (microsoft#24710) feat: autocontrolled `useTable` hook (microsoft#24688) feat: add dialog properties to getNativeElementProps (microsoft#24698) Using migrate rather than upgrade term (microsoft#24695) ...
For a
FocusZonewithshouldResetActiveElementWhenTabFromZoneprop specified, when it is updated before receiving focus, the zone does not update tabIndex accordingly.In this example: https://codesandbox.io/s/fluent-ui-example-forked-hq2lzn
This is because when one more message is added to
FocusZone, the zone does not reset tabIndex, while it shouldNote that initially I wanted to reset tabIndex on FocusZone re-render. But this is not enough as FocusZone's children can be updated without FocusZone itself re-render. In the end I reset tabIndex every time a keydown is captured, and focus is outside of the zone.