Update Tooltip API with visible controlled prop, and onVisibleChange event#18610
Update Tooltip API with visible controlled prop, and onVisibleChange event#18610behowell merged 25 commits intomicrosoft:masterfrom
Conversation
…ooltip-beforeshow
…ooltip-beforeshow
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 37b972a757b0521cbce537b45c992c164d3fe62f (build) |
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| buttonNative | mount | 129 | 138 | 5000 | Possible regression |
All results
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| Avatar | mount | 878 | 908 | 5000 | |
| BaseButton | mount | 995 | 970 | 5000 | |
| Breadcrumb | mount | 2902 | 2992 | 1000 | |
| ButtonNext | mount | 603 | 599 | 5000 | |
| Checkbox | mount | 1720 | 1703 | 5000 | |
| CheckboxBase | mount | 1471 | 1482 | 5000 | |
| ChoiceGroup | mount | 5309 | 5308 | 5000 | |
| ComboBox | mount | 1056 | 1070 | 1000 | |
| CommandBar | mount | 10823 | 11090 | 1000 | |
| ContextualMenu | mount | 6712 | 6750 | 1000 | |
| DefaultButton | mount | 1311 | 1252 | 5000 | |
| DetailsRow | mount | 4106 | 4203 | 5000 | |
| DetailsRowFast | mount | 4087 | 4090 | 5000 | |
| DetailsRowNoStyles | mount | 3829 | 3920 | 5000 | |
| Dialog | mount | 2210 | 2217 | 1000 | |
| DocumentCardTitle | mount | 152 | 155 | 1000 | |
| Dropdown | mount | 3638 | 3632 | 5000 | |
| FluentProviderNext | mount | 7607 | 7663 | 5000 | |
| FocusTrapZone | mount | 1949 | 1923 | 5000 | |
| FocusZone | mount | 1984 | 1974 | 5000 | |
| IconButton | mount | 1979 | 2038 | 5000 | |
| Label | mount | 364 | 383 | 5000 | |
| Layer | mount | 1966 | 1946 | 5000 | |
| Link | mount | 550 | 536 | 5000 | |
| MakeStyles | mount | 1964 | 1989 | 50000 | |
| MenuButton | mount | 1646 | 1630 | 5000 | |
| MessageBar | mount | 2285 | 2243 | 5000 | |
| Nav | mount | 3591 | 3666 | 1000 | |
| OverflowSet | mount | 1177 | 1159 | 5000 | |
| Panel | mount | 2300 | 2217 | 1000 | |
| Persona | mount | 889 | 896 | 1000 | |
| Pivot | mount | 1568 | 1594 | 1000 | |
| PrimaryButton | mount | 1429 | 1425 | 5000 | |
| Rating | mount | 8786 | 8605 | 5000 | |
| SearchBox | mount | 1481 | 1482 | 5000 | |
| Shimmer | mount | 2798 | 2799 | 5000 | |
| Slider | mount | 2175 | 2202 | 5000 | |
| SpinButton | mount | 5415 | 5378 | 5000 | |
| Spinner | mount | 457 | 464 | 5000 | |
| SplitButton | mount | 3422 | 3443 | 5000 | |
| Stack | mount | 561 | 558 | 5000 | |
| StackWithIntrinsicChildren | mount | 1777 | 1827 | 5000 | |
| StackWithTextChildren | mount | 5222 | 5247 | 5000 | |
| SwatchColorPicker | mount | 11290 | 11097 | 5000 | |
| Tabs | mount | 1525 | 1500 | 1000 | |
| TagPicker | mount | 2662 | 2664 | 5000 | |
| TeachingBubble | mount | 12557 | 12312 | 5000 | |
| Text | mount | 489 | 473 | 5000 | |
| TextField | mount | 1545 | 1564 | 5000 | |
| ThemeProvider | mount | 1260 | 1293 | 5000 | |
| ThemeProvider | virtual-rerender | 632 | 668 | 5000 | |
| Toggle | mount | 906 | 901 | 5000 | |
| buttonNative | mount | 129 | 138 | 5000 | Possible regression |
Perf Analysis (@fluentui/react-northstar)
Perf tests with no regressions
| Scenario | Current PR Ticks | Baseline Ticks | Ratio |
|---|---|---|---|
| DatepickerMinimalPerf.default | 6627 | 5729 | 1.16:1 |
| TreeWith60ListItems.default | 209 | 181 | 1.15:1 |
| CarouselMinimalPerf.default | 545 | 511 | 1.07:1 |
| BoxMinimalPerf.default | 412 | 388 | 1.06:1 |
| GridMinimalPerf.default | 393 | 372 | 1.06:1 |
| LabelMinimalPerf.default | 463 | 438 | 1.06:1 |
| AnimationMinimalPerf.default | 466 | 443 | 1.05:1 |
| DropdownManyItemsPerf.default | 778 | 738 | 1.05:1 |
| DropdownMinimalPerf.default | 3541 | 3383 | 1.05:1 |
| IconMinimalPerf.default | 708 | 676 | 1.05:1 |
| AttachmentSlotsPerf.default | 1223 | 1177 | 1.04:1 |
| ChatWithPopoverPerf.default | 413 | 399 | 1.04:1 |
| LayoutMinimalPerf.default | 422 | 406 | 1.04:1 |
| LoaderMinimalPerf.default | 777 | 746 | 1.04:1 |
| SkeletonMinimalPerf.default | 401 | 384 | 1.04:1 |
| ButtonSlotsPerf.default | 608 | 593 | 1.03:1 |
| CardMinimalPerf.default | 614 | 598 | 1.03:1 |
| ChatMinimalPerf.default | 754 | 730 | 1.03:1 |
| CheckboxMinimalPerf.default | 2977 | 2899 | 1.03:1 |
| PortalMinimalPerf.default | 193 | 187 | 1.03:1 |
| RadioGroupMinimalPerf.default | 518 | 503 | 1.03:1 |
| ReactionMinimalPerf.default | 441 | 430 | 1.03:1 |
| RefMinimalPerf.default | 252 | 245 | 1.03:1 |
| TreeMinimalPerf.default | 894 | 867 | 1.03:1 |
| FlexMinimalPerf.default | 329 | 323 | 1.02:1 |
| FormMinimalPerf.default | 471 | 462 | 1.02:1 |
| InputMinimalPerf.default | 1377 | 1354 | 1.02:1 |
| ListMinimalPerf.default | 584 | 572 | 1.02:1 |
| MenuMinimalPerf.default | 974 | 951 | 1.02:1 |
| ProviderMinimalPerf.default | 1106 | 1080 | 1.02:1 |
| SplitButtonMinimalPerf.default | 4277 | 4173 | 1.02:1 |
| TableMinimalPerf.default | 458 | 450 | 1.02:1 |
| ListCommonPerf.default | 733 | 729 | 1.01:1 |
| ListNestedPerf.default | 635 | 630 | 1.01:1 |
| ProviderMergeThemesPerf.default | 1803 | 1790 | 1.01:1 |
| VideoMinimalPerf.default | 700 | 692 | 1.01:1 |
| EmbedMinimalPerf.default | 4580 | 4572 | 1:1 |
| ItemLayoutMinimalPerf.default | 1371 | 1366 | 1:1 |
| MenuButtonMinimalPerf.default | 1876 | 1881 | 1:1 |
| PopupMinimalPerf.default | 666 | 664 | 1:1 |
| SliderMinimalPerf.default | 1734 | 1732 | 1:1 |
| TextMinimalPerf.default | 390 | 389 | 1:1 |
| TooltipMinimalPerf.default | 1123 | 1121 | 1:1 |
| DialogMinimalPerf.default | 822 | 830 | 0.99:1 |
| DividerMinimalPerf.default | 411 | 414 | 0.99:1 |
| SegmentMinimalPerf.default | 382 | 385 | 0.99:1 |
| TableManyItemsPerf.default | 2178 | 2202 | 0.99:1 |
| TextAreaMinimalPerf.default | 564 | 569 | 0.99:1 |
| AlertMinimalPerf.default | 316 | 323 | 0.98:1 |
| ButtonMinimalPerf.default | 188 | 192 | 0.98:1 |
| ImageMinimalPerf.default | 450 | 458 | 0.98:1 |
| RosterPerf.default | 1269 | 1300 | 0.98:1 |
| CustomToolbarPrototype.default | 4174 | 4247 | 0.98:1 |
| ToolbarMinimalPerf.default | 1039 | 1065 | 0.98:1 |
| ButtonOverridesMissPerf.default | 1868 | 1916 | 0.97:1 |
| HeaderMinimalPerf.default | 420 | 432 | 0.97:1 |
| ListWith60ListItems.default | 702 | 726 | 0.97:1 |
| StatusMinimalPerf.default | 755 | 777 | 0.97:1 |
| AttachmentMinimalPerf.default | 173 | 180 | 0.96:1 |
| AvatarMinimalPerf.default | 219 | 228 | 0.96:1 |
| ChatDuplicateMessagesPerf.default | 310 | 333 | 0.93:1 |
| HeaderSlotsPerf.default | 882 | 958 | 0.92:1 |
| AccordionMinimalPerf.default | 159 | 177 | 0.9:1 |
…ooltip-beforeshow
|
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 4a8b91e:
|
|
Using an imperative ref for this is generally an anti-pattern in React. It would be much more aligned with best practices to allow the component to be controlled with an Is there are requirement to use an imperative ref for this ? |
packages/react-examples/src/react-tooltip/Tooltip/Tooltip.stories.tsx
Outdated
Show resolved
Hide resolved
|
@ling1726 Thanks for the review! I'll update it to use a controlled |
📊 Bundle size reportUnchanged fixtures
|
|
It would be great to see some e2e tests with cypress for this, I can guide you to writing them if you'd like |
I'm planning to write some tests for tooltip soon; but I wanted to get this PR in first. I'll follow up with you about cypress. |
…ooltip-beforeshow
|
🎉 Handy links: |
|
🎉 Handy links: |
|
🎉 Handy links: |
|
🎉 Handy links: |
…event (microsoft#18610) * Add `visible` prop that can be used to control the tooltip's visibility programmatically. * Add `onVisibleChange` event to notify controlled and uncontrolled tooltips when the visibility should change. * Replace `targetRef` with `target` for specifying the target of the tooltip * If `target` is not specified, use a ref on the child element to determine the target automatically. This replaces the previous method of using the PointerEnter/Focus event's currentTarget prop to determine the target. This was required because now the tooltip can be made visible without a corresponding event. * Remove the `onlyIfTruncated` prop. The functionality can be implemented by using a controlled `visible` prop. There's an example in Tooltip.stories.tsx.
Pull request checklist
$ yarn changeDescription of changes
This PR includes a few updates to the Tooltip API:
visibleprop that can be used to control the tooltip's visibility programmatically.onVisibleChangeevent to notify controlled and uncontrolled tooltips when the visibility should change.targetRefwithtargetfor specifying the target of the tooltiptargetis not specified, use a ref on the child element to determine the target automatically. This replaces the previous method of using the PointerEnter/Focus event's currentTarget prop to determine the target. This was required because now the tooltip can be made visible without a corresponding event.onlyIfTruncatedprop. The functionality can be implemented by using a controlledvisibleprop. There's an example in Tooltip.stories.tsx.