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

Remove KeytipData usage from Link, Checkbox, Toggle (react-next) #13742

Merged
merged 12 commits into from Jul 10, 2020

Conversation

xugao
Copy link
Contributor

@xugao xugao commented Jun 22, 2020

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ yarn change

Description of changes

Removed KeytipData usage from Link, Checkbox, Toggle components:

  • Deprecated keytipProps
  • A new way to support Keytip for a given component: use useKeytipRef hook and pass the ref to the targeted component

How to apply Keytip to a component after this change, here is an example:

import { Checkbox, useKeytipRef } from '@fluentui/react-next';

const ref = useKeytipRef({...});
<Checkbox ref={ref} />

You can also find usage examples in Keytips.Basic.Example.tsx

Focus areas to test

(optional)

<Toggle onText="Yes" offText="No" keytipData={toggleKeytipData} />
<span>
Go to{' '}
<Link keytipData={linkKeytipData} href="http://www.bing.com" target="_blank">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before:

<Link keytipProps={keytipMap.LinkKeytip} href="http://www.bing.com" target="_blank">

After:

const linkKeytipData = useKeytipData({ keytipProps: keytipMap.LinkKeytip });
<Link keytipData={linkKeytipData} href="http://www.bing.com" target="_blank">

Copy link
Member

Choose a reason for hiding this comment

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

Instead why not this?

<Keytip {...keytipProps}>
  <Link href="..." target="...">...</Link>
</Keytip>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code:

Before:

<Link keytipProps={keytipMap.LinkKeytip} href="http://www.bing.com" target="_blank">

After:

const linkRef = useKeytipRef({ keytipProps: keytipMap.LinkKeytip });
<Link ref={linkRef} href="http://www.bing.com" target="_blank">

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Jun 22, 2020

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 1049 1008 5000
ButtonNext mount 654 681 5000
Checkbox mount 1802 1736 5000
CheckboxBase mount 1487 1552 5000
CheckboxNext mount 1763 1737 5000
ChoiceGroup mount 5479 5534 5000
ComboBox mount 985 1008 1000
CommandBar mount 8360 8327 1000
ContextualMenu mount 15158 14803 1000
DefaultButton mount 1252 1234 5000
DetailsRow mount 4048 4052 5000
DetailsRowFast mount 4065 4011 5000
DetailsRowNoStyles mount 3727 3874 5000
Dialog mount 1637 1691 1000
DocumentCardTitle mount 1927 2033 1000
Dropdown mount 3120 2820 5000
FocusZone mount 2049 1994 5000
IconButton mount 2113 1992 5000
Label mount 390 357 5000
Link mount 483 530 5000
LinkNext mount 531 506 5000
MenuButton mount 1656 1663 5000
Nav mount 3573 3630 1000
Panel mount 1642 1561 1000
Persona mount 921 947 1000
Pivot mount 1514 1595 1000
PivotNext mount 1500 1519 1000
PrimaryButton mount 1421 1465 5000
SearchBox mount 1506 1498 5000
SearchBoxNext mount 1474 1504 5000
Slider mount 1664 1702 5000
SliderNext mount 2093 2121 5000
Spinner mount 502 472 5000
SplitButton mount 3482 3534 5000
Stack mount 562 594 5000
StackWithIntrinsicChildren mount 2202 2178 5000
StackWithTextChildren mount 5708 5724 5000
TagPicker mount 3163 3078 5000
Text mount 471 496 5000
TextField mount 1675 1650 5000
ThemeProvider mount 3232 3323 5000
ThemeProvider virtual-rerender 543 535 5000
Toggle mount 958 992 5000
ToggleNext mount 887 913 5000
button mount 111 115 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.51 0.51 1:1 2000 1026
🦄 Button.Fluent 0.13 0.21 0.62:1 5000 632
🔧 Checkbox.Fluent 0.71 0.37 1.92:1 1000 708
🎯 Dialog.Fluent 0.17 0.24 0.71:1 5000 844
🔧 Dropdown.Fluent 3.22 0.52 6.19:1 1000 3215
🔧 Icon.Fluent 0.16 0.06 2.67:1 5000 779
🦄 Image.Fluent 0.08 0.12 0.67:1 5000 399
🔧 Slider.Fluent 1.75 0.43 4.07:1 1000 1747
🔧 Text.Fluent 0.08 0.03 2.67:1 5000 397
🦄 Tooltip.Fluent 0.11 19.27 0.01:1 5000 571

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
TableMinimalPerf.default 458 385 1.19:1
LayoutMinimalPerf.default 459 401 1.14:1
AvatarMinimalPerf.default 572 507 1.13:1
ButtonMinimalPerf.default 209 187 1.12:1
RefMinimalPerf.default 232 207 1.12:1
AlertMinimalPerf.default 357 323 1.11:1
RadioGroupMinimalPerf.default 524 481 1.09:1
TextAreaMinimalPerf.default 579 535 1.08:1
ChatMinimalPerf.default 732 681 1.07:1
MenuMinimalPerf.default 1022 955 1.07:1
CardMinimalPerf.default 655 619 1.06:1
DialogMinimalPerf.default 899 851 1.06:1
ImageMinimalPerf.default 448 422 1.06:1
StatusMinimalPerf.default 816 767 1.06:1
CheckboxMinimalPerf.default 3282 3122 1.05:1
ListMinimalPerf.default 556 528 1.05:1
Dialog.Fluent 844 807 1.05:1
InputMinimalPerf.default 1250 1198 1.04:1
ListCommonPerf.default 1113 1074 1.04:1
TreeMinimalPerf.default 989 949 1.04:1
Tooltip.Fluent 571 549 1.04:1
PortalMinimalPerf.default 125 121 1.03:1
ProviderMergeThemesPerf.default 2105 2039 1.03:1
IconMinimalPerf.default 790 767 1.03:1
AnimationMinimalPerf.default 425 415 1.02:1
ListNestedPerf.default 1074 1055 1.02:1
ProviderMinimalPerf.default 983 966 1.02:1
Button.Fluent 632 622 1.02:1
Icon.Fluent 779 765 1.02:1
Slider.Fluent 1747 1705 1.02:1
AttachmentMinimalPerf.default 171 169 1.01:1
DividerMinimalPerf.default 425 421 1.01:1
FormMinimalPerf.default 490 487 1.01:1
LoaderMinimalPerf.default 857 851 1.01:1
MenuButtonMinimalPerf.default 1715 1696 1.01:1
TooltipMinimalPerf.default 838 826 1.01:1
ListWith60ListItems.default 1212 1210 1:1
PopupMinimalPerf.default 754 752 1:1
SplitButtonMinimalPerf.default 4238 4231 1:1
TableManyItemsPerf.default 2599 2611 1:1
VideoMinimalPerf.default 734 732 1:1
Avatar.Fluent 1026 1031 1:1
Dropdown.Fluent 3215 3225 1:1
ChatDuplicateMessagesPerf.default 458 463 0.99:1
DropdownMinimalPerf.default 3234 3256 0.99:1
GridMinimalPerf.default 392 394 0.99:1
HeaderMinimalPerf.default 389 394 0.99:1
HeaderSlotsPerf.default 912 918 0.99:1
ItemLayoutMinimalPerf.default 1492 1511 0.99:1
AttachmentSlotsPerf.default 1257 1280 0.98:1
CarouselMinimalPerf.default 527 537 0.98:1
ReactionMinimalPerf.default 427 436 0.98:1
SliderMinimalPerf.default 1699 1725 0.98:1
TextMinimalPerf.default 380 389 0.98:1
AccordionMinimalPerf.default 165 170 0.97:1
SegmentMinimalPerf.default 375 388 0.97:1
CustomToolbarPrototype.default 3903 4006 0.97:1
Text.Fluent 397 408 0.97:1
ButtonSlotsPerf.default 674 702 0.96:1
EmbedMinimalPerf.default 2147 2244 0.96:1
Checkbox.Fluent 708 736 0.96:1
LabelMinimalPerf.default 471 495 0.95:1
BoxMinimalPerf.default 393 417 0.94:1
DropdownManyItemsPerf.default 860 916 0.94:1
FlexMinimalPerf.default 308 331 0.93:1
ToolbarMinimalPerf.default 1057 1142 0.93:1
TreeWith60ListItems.default 232 252 0.92:1
ChatWithPopoverPerf.default 501 548 0.91:1
HierarchicalTreeMinimalPerf.default 444 500 0.89:1
Image.Fluent 399 484 0.82:1

@size-auditor
Copy link

size-auditor bot commented Jun 22, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react office-ui-fabric-react-KeytipData 12.531 kB 12.919 kB ExceedsBaseline     388 bytes
office-ui-fabric-react fluentui-react-next-KeytipData 12.531 kB 12.919 kB ExceedsBaseline     388 bytes
office-ui-fabric-react fluentui-react-next-KeytipLayer 97.659 kB 97.788 kB ExceedsBaseline     129 bytes
office-ui-fabric-react office-ui-fabric-react-KeytipLayer 97.659 kB 97.788 kB ExceedsBaseline     129 bytes
office-ui-fabric-react office-ui-fabric-react-CommandBar 191.639 kB 191.516 kB BelowBaseline     -123 bytes
office-ui-fabric-react office-ui-fabric-react-Link 42.83 kB 42.707 kB BelowBaseline     -123 bytes
office-ui-fabric-react fluentui-react-next-CommandBar 191.639 kB 191.516 kB BelowBaseline     -123 bytes
office-ui-fabric-react office-ui-fabric-react-SearchBox 177.702 kB 177.576 kB BelowBaseline     -126 bytes
office-ui-fabric-react fluentui-react-next-ContextualMenu 149.058 kB 148.931 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-DocumentCard 205.686 kB 205.559 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-ShimmeredDetailsList 222.934 kB 222.807 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Dropdown 222.797 kB 222.67 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-DocumentCard 205.686 kB 205.559 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-SearchBox 177.529 kB 177.402 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Dialog 199.524 kB 199.397 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-DetailsList 212.26 kB 212.133 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-SpinButton 183.741 kB 183.614 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-ComboBox 235.333 kB 235.206 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-FloatingPicker 230.058 kB 229.931 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Dialog 199.565 kB 199.438 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Breadcrumb 189.665 kB 189.538 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Button 183.993 kB 183.866 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-DetailsList 212.26 kB 212.133 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-SwatchColorPicker 181.945 kB 181.818 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-TeachingBubble 195.902 kB 195.775 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-ContextualMenu 149.058 kB 148.931 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Checkbox 63.669 kB 63.542 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Breadcrumb 189.665 kB 189.538 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Toggle 49.581 kB 49.454 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Facepile 200.549 kB 200.422 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-MessageBar 179.818 kB 179.691 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Pivot 179.097 kB 178.97 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-ShimmeredDetailsList 222.934 kB 222.807 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Pickers 272.663 kB 272.536 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Nav 179.121 kB 178.994 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-GroupedList 120.313 kB 120.186 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Grid 171.535 kB 171.408 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Panel 191.034 kB 190.907 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Panel 191.034 kB 190.907 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-ComboBox 235.333 kB 235.206 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Nav 179.121 kB 178.994 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-SpinButton 183.717 kB 183.59 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-MessageBar 179.818 kB 179.691 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-SwatchColorPicker 181.949 kB 181.822 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Pickers 272.663 kB 272.536 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Pivot 176.888 kB 176.761 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-TeachingBubble 195.902 kB 195.775 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-FloatingPicker 230.058 kB 229.931 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Facepile 200.549 kB 200.422 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-SelectedItemsList 223.336 kB 223.209 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-GroupedList 120.313 kB 120.186 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Grid 171.535 kB 171.408 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-SelectedItemsList 219.52 kB 219.393 kB BelowBaseline     -127 bytes
office-ui-fabric-react office-ui-fabric-react-Dropdown 222.797 kB 222.67 kB BelowBaseline     -127 bytes
office-ui-fabric-react fluentui-react-next-Toggle 54.673 kB 47.137 kB BelowBaseline     -7.536 kB
office-ui-fabric-react fluentui-react-next-Checkbox 53.253 kB 45.644 kB BelowBaseline     -7.609 kB
office-ui-fabric-react fluentui-react-next-Link 45.844 kB 38.215 kB BelowBaseline     -7.629 kB

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

Baseline commit: d43db14983c012854c144263821109e09ed15310 (build)

@xugao xugao force-pushed the xgao/useKeytipData branch 3 times, most recently from fe87fa5 to 656b064 Compare June 25, 2020 16:16
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 25, 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 10d068e:

Sandbox Source
Fluent UI Button Configuration
microsoft/fluentui: codesandbox-react-template Configuration

@xugao xugao requested a review from kelseyyoung June 25, 2020 19:44
@xugao xugao force-pushed the xgao/useKeytipData branch 2 times, most recently from 1ade513 to 2cba581 Compare July 8, 2020 00:57
@xugao
Copy link
Contributor Author

xugao commented Jul 8, 2020

@dzearing @khmakoto @kelseyyoung - I updated the code and added useKeytipRef hook.

The idea is that the hook will return a ref which then user can pass the ref to whichever component keytip is targeting. The ref will allow the hook to access the root element that it's targeting and sets proper keytip attributes based on (optional) data attributes set within the root element.

@xugao xugao requested a review from kelseyyoung July 8, 2020 16:11
@kelseyyoung
Copy link
Contributor

@xugao would the ref approach be problematic if the 'ref' attribute for the component was already used?

@xugao
Copy link
Contributor Author

xugao commented Jul 8, 2020

@kelseyyoung - user can merge multiple refs into one. we have an implementation in @fluentui/react-hooks package here

* Optional keytip for this Link
* Optional keytip.
*
* @deprecated This no longer works. Use `useKeytipData` hook instead.
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem like the right deprecation message - is there any way to have this value deprecated in v7 with an alternative implementation for customers?

Copy link
Member

Choose a reason for hiding this comment

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

If we can deprecate it (but keep it functional)_ with the viable alternative in v7, and then remove it in v8, that's a better user experience. They can update to wrapping things before the upgrade, right now, in v7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately user can't use the new approach on V7 components, because they don't support passing ref to the root element

@xugao xugao merged commit d07846f into microsoft:master Jul 10, 2020
@msft-github-bot
Copy link
Contributor

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

Handy links:

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