Skip to content

react-button - Simplify prop merging#18814

Merged
ling1726 merged 36 commits intomicrosoft:masterfrom
bsunderhus:simplify-prop-merging-react-button
Oct 1, 2021
Merged

react-button - Simplify prop merging#18814
ling1726 merged 36 commits intomicrosoft:masterfrom
bsunderhus:simplify-prop-merging-react-button

Conversation

@bsunderhus
Copy link
Contributor

Pull request checklist

  • Include a change request file using $ yarn change

Description of changes

Implements changes proposed by the RFC #18721 on react-button

@bsunderhus bsunderhus requested review from a team and khmakoto July 2, 2021 12:20
@bsunderhus bsunderhus self-assigned this Jul 2, 2021
@bsunderhus bsunderhus requested review from a team and dzearing as code owners July 2, 2021 12:20
@size-auditor
Copy link

size-auditor bot commented Jul 2, 2021

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 862d142c760b40df8c21a43b41bf513c153df69e (build)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 2, 2021

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 fbcdb33:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 2, 2021

Perf Analysis (@fluentui/react)

Scenario Render type Master Ticks PR Ticks Iterations Status
ButtonNext mount 518 554 5000 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1077 1093 5000
BaseButton mount 1059 1063 5000
Breadcrumb mount 2838 2796 1000
ButtonNext mount 518 554 5000 Possible regression
Checkbox mount 1773 1791 5000
CheckboxBase mount 1537 1514 5000
ChoiceGroup mount 5316 5402 5000
ComboBox mount 1058 1100 1000
CommandBar mount 10849 10897 1000
ContextualMenu mount 6950 6919 1000
DefaultButton mount 1309 1310 5000
DetailsRow mount 4096 4050 5000
DetailsRowFast mount 4169 4067 5000
DetailsRowNoStyles mount 3921 3987 5000
Dialog mount 2629 2650 1000
DocumentCardTitle mount 196 194 1000
Dropdown mount 3631 3613 5000
FluentProviderNext mount 3389 3397 5000
FluentProviderWithTheme mount 231 217 10
FluentProviderWithTheme virtual-rerender 107 113 10
FluentProviderWithTheme virtual-rerender-with-unmount 252 252 10
FocusTrapZone mount 2036 1954 5000
FocusZone mount 1926 1954 5000
IconButton mount 2016 2007 5000
Label mount 387 375 5000
Layer mount 3367 3376 5000
Link mount 537 532 5000
MakeStyles mount 1938 1946 50000
MenuButton mount 1721 1672 5000
MessageBar mount 2160 2219 5000
Nav mount 3657 3636 1000
OverflowSet mount 1240 1251 5000
Panel mount 2511 2540 1000
Persona mount 927 921 1000
Pivot mount 1584 1601 1000
PrimaryButton mount 1470 1482 5000
Rating mount 8915 8825 5000
SearchBox mount 1560 1566 5000
Shimmer mount 2903 2939 5000
Slider mount 2155 2168 5000
SpinButton mount 5544 5580 5000
Spinner mount 492 470 5000
SplitButton mount 3490 3514 5000
Stack mount 567 583 5000
StackWithIntrinsicChildren mount 1975 1985 5000
StackWithTextChildren mount 5399 5378 5000
SwatchColorPicker mount 11447 11518 5000
Tabs mount 1557 1604 1000
TagPicker mount 2955 2981 5000
TeachingBubble mount 13740 13776 5000
Text mount 487 476 5000
TextField mount 1580 1587 5000
ThemeProvider mount 1306 1310 5000
ThemeProvider virtual-rerender 654 660 5000
ThemeProvider virtual-rerender-with-unmount 2129 2091 5000
Toggle mount 916 920 5000
buttonNative mount 150 153 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ChatDuplicateMessagesPerf.default 356 325 1.1:1
ChatWithPopoverPerf.default 464 427 1.09:1
RefMinimalPerf.default 267 246 1.09:1
BoxMinimalPerf.default 407 381 1.07:1
TreeWith60ListItems.default 215 203 1.06:1
AttachmentMinimalPerf.default 199 190 1.05:1
AvatarMinimalPerf.default 239 227 1.05:1
GridMinimalPerf.default 405 387 1.05:1
TreeMinimalPerf.default 932 888 1.05:1
CarouselMinimalPerf.default 544 525 1.04:1
FlexMinimalPerf.default 333 320 1.04:1
HeaderSlotsPerf.default 881 848 1.04:1
InputMinimalPerf.default 1489 1434 1.04:1
LabelMinimalPerf.default 447 429 1.04:1
ListWith60ListItems.default 755 728 1.04:1
RadioGroupMinimalPerf.default 530 508 1.04:1
MenuButtonMinimalPerf.default 1898 1841 1.03:1
IconMinimalPerf.default 743 723 1.03:1
AttachmentSlotsPerf.default 1241 1222 1.02:1
FormMinimalPerf.default 484 474 1.02:1
HeaderMinimalPerf.default 417 409 1.02:1
ListCommonPerf.default 742 727 1.02:1
ListNestedPerf.default 653 638 1.02:1
SkeletonMinimalPerf.default 414 405 1.02:1
StatusMinimalPerf.default 801 786 1.02:1
TableMinimalPerf.default 469 462 1.02:1
CustomToolbarPrototype.default 4583 4507 1.02:1
ButtonOverridesMissPerf.default 1988 1974 1.01:1
CheckboxMinimalPerf.default 3018 2994 1.01:1
DatepickerMinimalPerf.default 6096 6035 1.01:1
DropdownManyItemsPerf.default 805 796 1.01:1
DropdownMinimalPerf.default 3428 3400 1.01:1
ImageMinimalPerf.default 441 437 1.01:1
LayoutMinimalPerf.default 420 417 1.01:1
ListMinimalPerf.default 586 579 1.01:1
MenuMinimalPerf.default 958 945 1.01:1
RosterPerf.default 1404 1397 1.01:1
PopupMinimalPerf.default 652 645 1.01:1
AnimationMinimalPerf.default 459 459 1:1
EmbedMinimalPerf.default 4720 4716 1:1
LoaderMinimalPerf.default 767 765 1:1
PortalMinimalPerf.default 192 192 1:1
ProviderMergeThemesPerf.default 1820 1811 1:1
ReactionMinimalPerf.default 441 442 1:1
SplitButtonMinimalPerf.default 4751 4774 1:1
ToolbarMinimalPerf.default 1065 1066 1:1
CardMinimalPerf.default 647 656 0.99:1
DialogMinimalPerf.default 815 827 0.99:1
ItemLayoutMinimalPerf.default 1384 1404 0.99:1
SliderMinimalPerf.default 1851 1875 0.99:1
TableManyItemsPerf.default 2244 2267 0.99:1
TextMinimalPerf.default 404 408 0.99:1
TooltipMinimalPerf.default 1160 1176 0.99:1
ButtonMinimalPerf.default 214 218 0.98:1
ProviderMinimalPerf.default 1246 1275 0.98:1
SegmentMinimalPerf.default 404 413 0.98:1
ButtonSlotsPerf.default 622 638 0.97:1
ChatMinimalPerf.default 735 757 0.97:1
DividerMinimalPerf.default 420 435 0.97:1
VideoMinimalPerf.default 705 725 0.97:1
AlertMinimalPerf.default 307 324 0.95:1
TextAreaMinimalPerf.default 596 626 0.95:1
AccordionMinimalPerf.default 172 184 0.93:1

Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

Looks that this PR has merge conflicts, @bsunderhus can you please rebase it first?

@bsunderhus
Copy link
Contributor Author

Looks that this PR has merge conflicts, @bsunderhus can you please rebase it first?

I'll keep this PR on hold for now, as some divergent discussions are appearing on the subject

@layershifter layershifter added the Status: Blocked Resolution blocked by another issue label Jul 14, 2021
@layershifter layershifter removed the Status: Blocked Resolution blocked by another issue label Aug 31, 2021
@layershifter
Copy link
Member

As #19483 was merged, this is not blocked anymore.

@bsunderhus bsunderhus force-pushed the simplify-prop-merging-react-button branch from 3a05e23 to 420362c Compare September 15, 2021 10:41
@fabricteam
Copy link
Collaborator

fabricteam commented Sep 15, 2021

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-accordion
Accordion (including children components)
55.192 kB
17.419 kB
55.059 kB
17.394 kB
-133 B
-25 B
react-button
Button
22.326 kB
7.019 kB
23.224 kB
7.219 kB
898 B
200 B
react-button
CompoundButton
27.375 kB
7.862 kB
28.481 kB
8.173 kB
1.106 kB
311 B
react-button
MenuButton
24.52 kB
7.703 kB
25.249 kB
7.895 kB
729 B
192 B
react-button
SplitButton
29.642 kB
8.811 kB
30.737 kB
8.955 kB
1.095 kB
144 B
react-button
ToggleButton
31.24 kB
7.627 kB
32.45 kB
7.868 kB
1.21 kB
241 B
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
163.641 kB
46.827 kB
162.028 kB
46.198 kB
-1.613 kB
-629 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: FluentProvider & webLightTheme
32.188 kB
10.658 kB
react-link
Link
11.402 kB
4.59 kB
🤖 This report was generated against 862d142c760b40df8c21a43b41bf513c153df69e

>((props, ref) => {
export const Button: React.ForwardRefExoticComponent<
ButtonProps & React.RefAttributes<HTMLButtonElement>
> = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
Copy link
Member

Choose a reason for hiding this comment

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

declaring ForwardRefExoticComponent is a bit tangled up in Ben's forwardRef PR and Elizabeth's follow-on PR. @ecraig12345 - What should the declaration be if any?

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep that separate since the resolution is still not known on that one.

return <slots.root {...slotProps.root}>this is an anchor</slots.root>;
};

export const Span = (args: DefaultArgs) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

💜

shorthand.onKeyDown = onKeyDownHandler;
shorthand.onKeyUp = onKeyupHandler;
shorthand.role = shorthand.role ?? 'button';
shorthand.tabIndex = disabled && !disabledFocusable ? undefined : tabIndex ?? 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I half wonder if there's a way to mandate an href attribute if someone wants as: a, since otherwise it's effectively as: span, and then we don't need to do the weird keydown vs. keyup enter key dance. And also then we wouldn't need to specify tabindex unless it's disabled :)

Copy link
Member

Choose a reason for hiding this comment

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

I think this is something that we should explore, but this PR is very large as is, so I'll leave it till later to investigate this.

gap: buttonSpacing.smaller,
padding: `0 ${buttonSpacing.medium}`,

height: '24px',
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but we should probably adjust this to use padding/lineheight so the button text can wrap OK (I'll add it to the a11y issue 😄)

@varholak-peter varholak-peter dismissed their stale review September 25, 2021 16:21

Comments were addressed

@ling1726 ling1726 merged commit c5f91bf into microsoft:master Oct 1, 2021
@bsunderhus bsunderhus deleted the simplify-prop-merging-react-button branch October 1, 2021 13:40
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
* Updates button to simplify prop merging

* Change files

* Fix lint issues

* Adds react-aria deps

* Updates deps on react-accordion

* Change files

* Updates tests

* Change files

* Updates change

* Updates deps

* Updates deps

* Removes ExtractRef usage

* Updates API

* Updates deps

* Updates lock

* Change files

* Updating API to reflect aria button changes.

* Change files

* Removing type explosion.

* Fixing SplitButton fixture name.

* PR feedback.

* Updating package.json with newest versions.

* Updating comments in ToggleButton.

* Using getNativeElementProps in button.

* Bumping version of react-aria in react-button

* Invert names from argument and internal declaration on shorthands

* Update API

Co-authored-by: KHMakoto <Humberto.Morimoto@microsoft.com>
Co-authored-by: Lingfan Gao <lingfangao@hotmail.com>
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.

9 participants