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

Removing findDOMNode usage from Pivot #15558

Merged

Conversation

czearing
Copy link
Collaborator

@czearing czearing commented Oct 16, 2020

Pull request checklist

Description of changes

Removing findDOMNode usage from the react-tabs Pivot component.

Changing BaseButton's wrapper span to a fragment in react-internal

(This change was made to allow elementRef to recieve the root element.)

Before:
<span style={{ display: 'inline-block' }}>
   {Content}
   {this._shouldRenderMenu() && onRenderMenu(menuProps, this._onRenderMenu)}
</span>

After:
<>
   {Content}
   {this._shouldRenderMenu() && onRenderMenu(menuProps, this._onRenderMenu)}
</>

Adding an elementRef to Pivot's CommandButton

elementRef={overflowMenuButtonRef}
componentRef={overflowMenuButtonComponentRef}

Updating Pivot's CommandButton className

className={classNames.link + ' ' + classNames.overflowMenuButton}

Other Minor Changes

  • Fix Organizing the placement of ref and state in Pivot.base.tsx
  • Fix Removing setOverflowMenuButtonRef and replacing it with overflowMenuButtonRef

Focus areas to test

Pivot, BaseButton

@msft-github-bot
Copy link
Contributor

Thanks for submitting this change, but due to work currently in progress to prepare master for our version 8 beta release, we're asking contributors to either wait a couple weeks to submit changes (if it's not urgent) or submit to the new 7.0 branch (if it's urgent). See #15222 for more details. Thank you for your contribution and understanding!

Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

You'll probably need to update a bunch of snapshots (probably in all the packages) due to the button change.

@ecraig12345
Copy link
Member

Hmm actually never mind, the build seems to have passed with no snapshot changes??

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Oct 16, 2020

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 823 839 5000
BaseButtonCompat mount 909 911 5000
Breadcrumb mount 160759 160058 5000
Checkbox mount 1522 1495 5000
CheckboxBase mount 1290 1254 5000
ChoiceGroup mount 4710 4735 5000
ComboBox mount 974 993 1000
CommandBar mount 22066 22256 1000
ContextualMenu mount 6080 6111 1000
DefaultButtonCompat mount 1132 1180 5000
DetailsRow mount 3741 3673 5000
DetailsRowFast mount 3701 3726 5000
DetailsRowNoStyles mount 3552 3458 5000
Dialog mount 1503 1473 1000
DocumentCardTitle mount 1869 1854 1000
Dropdown mount 3771 3758 5000
FocusTrapZone mount 1834 1843 5000
FocusZone mount 1879 1860 5000
IconButtonCompat mount 1785 1800 5000
Label mount 342 337 5000
Layer mount 1844 1790 5000
Link mount 474 486 5000
MenuButtonCompat mount 1499 1492 5000
MessageBar mount 2099 2090 5000
Nav mount 3310 3287 1000
OverflowSet mount 1061 1039 5000
Panel mount 1442 1464 1000
Persona mount 884 889 1000
Pivot mount 1424 1437 1000
PrimaryButtonCompat mount 1275 1290 5000
Rating mount 7645 7663 5000
SearchBox mount 1300 1350 5000
Shimmer mount 2651 2563 5000
Slider mount 1931 1902 5000
SpinButton mount 5187 5239 5000
Spinner mount 417 423 5000
SplitButtonCompat mount 3194 3146 5000
Stack mount 510 520 5000
StackWithIntrinsicChildren mount 1913 1890 5000
StackWithTextChildren mount 4939 4952 5000
SwatchColorPicker mount 10232 10265 5000
TagPicker mount 2827 2704 5000
TeachingBubble mount 11783 11726 5000
Text mount 420 418 5000
TextField mount 1403 1387 5000
ThemeProvider mount 2009 2012 5000
ThemeProvider virtual-rerender 670 658 5000
Toggle mount 796 802 5000
button mount 581 559 5000
buttonNative mount 130 111 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.45 0.53 0.85:1 2000 890
🦄 Button.Fluent 0.12 0.2 0.6:1 5000 580
🔧 Checkbox.Fluent 0.64 0.35 1.83:1 1000 638
🎯 Dialog.Fluent 0.16 0.23 0.7:1 5000 807
🔧 Dropdown.Fluent 3.02 0.43 7.02:1 1000 3020
🔧 Icon.Fluent 0.14 0.06 2.33:1 5000 722
🦄 Image.Fluent 0.08 0.13 0.62:1 5000 415
🔧 Slider.Fluent 1.61 0.44 3.66:1 1000 1610
🔧 Text.Fluent 0.08 0.03 2.67:1 5000 388
🦄 Tooltip.Fluent 0.11 0.91 0.12:1 5000 569

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
LayoutMinimalPerf.default 469 417 1.12:1
ButtonSlotsPerf.default 649 590 1.1:1
SkeletonMinimalPerf.default 476 436 1.09:1
SegmentMinimalPerf.default 404 373 1.08:1
AttachmentMinimalPerf.default 172 162 1.06:1
IconMinimalPerf.default 726 682 1.06:1
TableMinimalPerf.default 448 421 1.06:1
Text.Fluent 388 366 1.06:1
ChatWithPopoverPerf.default 505 482 1.05:1
TextAreaMinimalPerf.default 522 496 1.05:1
TreeWith60ListItems.default 211 201 1.05:1
AttachmentSlotsPerf.default 1182 1137 1.04:1
CardMinimalPerf.default 605 582 1.04:1
HeaderMinimalPerf.default 400 384 1.04:1
LabelMinimalPerf.default 456 439 1.04:1
ListNestedPerf.default 590 570 1.04:1
SplitButtonMinimalPerf.default 3941 3783 1.04:1
AlertMinimalPerf.default 320 312 1.03:1
DropdownManyItemsPerf.default 761 741 1.03:1
EmbedMinimalPerf.default 1992 1941 1.03:1
GridMinimalPerf.default 373 363 1.03:1
PopupMinimalPerf.default 729 710 1.03:1
Image.Fluent 415 404 1.03:1
AnimationMinimalPerf.default 434 426 1.02:1
ListMinimalPerf.default 524 514 1.02:1
MenuMinimalPerf.default 909 887 1.02:1
MenuButtonMinimalPerf.default 1596 1568 1.02:1
ProviderMinimalPerf.default 1057 1041 1.02:1
SliderMinimalPerf.default 1623 1588 1.02:1
AccordionMinimalPerf.default 166 164 1.01:1
ButtonOverridesMissPerf.default 1764 1746 1.01:1
ChatMinimalPerf.default 651 644 1.01:1
FlexMinimalPerf.default 311 308 1.01:1
ListWith60ListItems.default 984 979 1.01:1
TableManyItemsPerf.default 2208 2190 1.01:1
CustomToolbarPrototype.default 4021 3974 1.01:1
ToolbarMinimalPerf.default 965 953 1.01:1
Dropdown.Fluent 3020 2984 1.01:1
AvatarMinimalPerf.default 476 474 1:1
DividerMinimalPerf.default 397 398 1:1
FormMinimalPerf.default 430 431 1:1
LoaderMinimalPerf.default 765 766 1:1
ReactionMinimalPerf.default 425 425 1:1
Avatar.Fluent 890 887 1:1
Slider.Fluent 1610 1609 1:1
BoxMinimalPerf.default 365 368 0.99:1
ButtonUseCssPerf.default 834 846 0.99:1
ButtonUseCssNestingPerf.default 1117 1133 0.99:1
ChatDuplicateMessagesPerf.default 451 456 0.99:1
CheckboxMinimalPerf.default 2941 2967 0.99:1
DropdownMinimalPerf.default 2958 2996 0.99:1
PortalMinimalPerf.default 163 164 0.99:1
ProviderMergeThemesPerf.default 2111 2141 0.99:1
TextMinimalPerf.default 376 379 0.99:1
TooltipMinimalPerf.default 830 835 0.99:1
TreeMinimalPerf.default 899 912 0.99:1
Dialog.Fluent 807 812 0.99:1
Tooltip.Fluent 569 572 0.99:1
CarouselMinimalPerf.default 462 473 0.98:1
ListCommonPerf.default 671 688 0.98:1
RadioGroupMinimalPerf.default 454 465 0.98:1
HeaderSlotsPerf.default 800 826 0.97:1
Button.Fluent 580 597 0.97:1
DialogMinimalPerf.default 802 837 0.96:1
StatusMinimalPerf.default 729 757 0.96:1
VideoMinimalPerf.default 624 650 0.96:1
InputMinimalPerf.default 1337 1411 0.95:1
ItemLayoutMinimalPerf.default 1295 1361 0.95:1
Checkbox.Fluent 638 669 0.95:1
Icon.Fluent 722 758 0.95:1
ButtonMinimalPerf.default 183 194 0.94:1
ImageMinimalPerf.default 383 406 0.94:1
RefMinimalPerf.default 242 263 0.92:1

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 16, 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 d63fd49:

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

@size-auditor
Copy link

size-auditor bot commented Oct 16, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-Button 179.767 kB 179.743 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Breadcrumb 184.328 kB 184.304 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Pickers 267.648 kB 267.624 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-MessageBar 173.763 kB 173.739 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Panel 185.496 kB 185.472 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-TeachingBubble 189.792 kB 189.768 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-SwatchColorPicker 175.858 kB 175.834 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Grid 166.345 kB 166.321 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-ComboBox 230.381 kB 230.357 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-SelectedItemsList 214.11 kB 214.086 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-SpinButton 179.063 kB 179.039 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Dialog 195.936 kB 195.912 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-DocumentCard 200.034 kB 200.01 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Dropdown 216.195 kB 216.171 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Nav 174.32 kB 174.296 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Facepile 194.758 kB 194.734 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-FloatingPicker 224.485 kB 224.461 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-SearchBox 172.791 kB 172.767 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-CommandBar 185.919 kB 185.895 kB BelowBaseline     -24 bytes
office-ui-fabric-react fluentui-react-Pivot 174.306 kB 174.182 kB BelowBaseline     -124 bytes

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

Baseline commit: d2fedc85c81bb0e2d86495ec1e928604bf2260f4 (build)

Comment on lines 69 to 86
const { componentRef, theme, linkSize, linkFormat, overflowBehavior } = props;
const pivotId: string = useId('Pivot');
let linkCollection = getLinkItems(props, pivotId);
const focusZoneRef = React.useRef<IFocusZone>(null);
const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties);
const overflowMenuButtonComponentRef = React.useRef<IButton>(null);
const pivotId: string = useId('Pivot');

const [selectedKey, setSelectedKey] = useControllableValue(props.selectedKey, props.defaultSelectedKey);

const { componentRef, theme, linkSize, linkFormat, overflowBehavior } = props;
// The overflow menu starts empty and items[] is updated as the overflow items change
const overflowMenuProps: IContextualMenuProps = {
items: [],
doNotLayer: true,
alignTargetEdge: true,
directionalHint: DirectionalHint.bottomRightEdge,
};

let classNames: { [key in keyof IPivotStyles]: string };
const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(props, divProperties);

let linkCollection = getLinkItems(props, pivotId);
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) out of curiosity, why are you moving around so many lines of code in this function? It's fine to clean things up if the code is messy, but this doesn't necessarily seem better than it was before. (E.g. previously, overflowMenuProps was declared closer to where it's used, which makes more sense to me). It's not necessarily a problem, but it seems unnecessary and makes the diff harder to read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I reverted the overflowMenuProps move and the diffing should be improved. The intention is to help keep consistency in Pivot’s useRef and useState/useControllableValue placement to follow patterns in other functional components.

@ecraig12345 ecraig12345 merged commit b4472b1 into microsoft:master Oct 17, 2020
@msft-github-bot
Copy link
Contributor

🎉@fluentui/react-tabs@v1.0.0-beta.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.

Pivot (next): remove findDOMNode usage
6 participants