Skip to content

fix: react-combobox perf improvements#26191

Merged
smhigley merged 2 commits intomicrosoft:masterfrom
smhigley:combobox-perf
Jan 6, 2023
Merged

fix: react-combobox perf improvements#26191
smhigley merged 2 commits intomicrosoft:masterfrom
smhigley:combobox-perf

Conversation

@smhigley
Copy link
Contributor

@smhigley smhigley commented Jan 6, 2023

Addresses perf bullets from #26069

Changes

  • In useCombobox, popupWidth created a new object assigned to listbox.style every render. Now the object is created in the useState hook, and only updated when opened/closed.
  • In useTriggerListboxSlots, listbox event handlers every render. Now it uses useEventCallback, and should only update on open/close.
  • selectOption and setOpen were recreated every render, and since they are used in the combobox context, they caused options to re-render. Now they use useCallback.

@smhigley smhigley requested a review from spmonahan January 6, 2023 02:44
@smhigley smhigley self-assigned this Jan 6, 2023
@smhigley smhigley requested a review from a team as a code owner January 6, 2023 02:44
@github-actions github-actions bot added this to the January Project Cycle Q1 2023 milestone Jan 6, 2023
@size-auditor
Copy link

size-auditor bot commented Jan 6, 2023

Asset size changes

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

Baseline commit: 54b6220d442231ffa0c3df88359f53373690da6f (build)

@fabricteam
Copy link
Collaborator

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-combobox
Combobox (including child components)
79.945 kB
25.57 kB
80.106 kB
25.637 kB
161 B
67 B
react-combobox
ComboboxField
77.141 kB
25.532 kB
77.302 kB
25.597 kB
161 B
65 B
react-combobox
Dropdown (including child components)
79.179 kB
25.499 kB
79.31 kB
25.567 kB
131 B
68 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
59.888 kB
16.652 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
188.928 kB
53.088 kB
react-components
react-components: FluentProvider & webLightTheme
34.379 kB
11.322 kB
react-portal-compat
PortalCompatProvider
6.069 kB
2.053 kB
🤖 This report was generated against 54b6220d442231ffa0c3df88359f53373690da6f

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 6, 2023

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 5a735cd:

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

@fabricteam
Copy link
Collaborator

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1293 1295 5000
Button mount 835 829 5000
FluentProvider mount 1542 1544 5000
FluentProviderWithTheme mount 618 640 10
FluentProviderWithTheme virtual-rerender 525 522 10
FluentProviderWithTheme virtual-rerender-with-unmount 630 614 10
MakeStyles mount 1836 1780 50000
Persona mount 2721 2903 5000
SpinButton mount 2302 2482 5000

@fabricteam
Copy link
Collaborator

🕵 fluentuiv9 No visual regressions between this PR and main

Copy link
Contributor

@spmonahan spmonahan left a comment

Choose a reason for hiding this comment

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

🎊

@smhigley smhigley merged commit d7a98c9 into microsoft:master Jan 6, 2023
q1b pushed a commit to q1b/fluentui that referenced this pull request Jan 24, 2023
- In useCombobox, popupWidth created a new object assigned to listbox.style every render. Now the object is created in the useState hook, and only updated when opened/closed.
- In useTriggerListboxSlots, listbox event handlers every render. Now it uses useEventCallback, and should only update on open/close.
- selectOption and setOpen were recreated every render, and since they are used in the combobox context, they caused options to re-render. Now they use useCallback.
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
- In useCombobox, popupWidth created a new object assigned to listbox.style every render. Now the object is created in the useState hook, and only updated when opened/closed.
- In useTriggerListboxSlots, listbox event handlers every render. Now it uses useEventCallback, and should only update on open/close.
- selectOption and setOpen were recreated every render, and since they are used in the combobox context, they caused options to re-render. Now they use useCallback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants