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

feat(react-menu, react-positioning): update maxSize to prevent double scrollbar for Menu in small viewport #28622

Merged
merged 10 commits into from
Jul 25, 2023

Conversation

YuanboXue-Amber
Copy link
Contributor

@YuanboXue-Amber YuanboXue-Amber commented Jul 24, 2023

Fix 1.a in #28623.

Previous Behavior

A menu in small viewport needs autoSize to become scrollable. But if the menu has scrollable menu group inside, it can show double scrollbar:
https://codesandbox.io/s/blue-framework-mstvsn?file=/example.tsx
Screenshot 2023-07-24 at 15 15 58

The expected behavior is to shrink the scrollable menu group to fit the entire menu in the viewport.
But this is hard to achieve from user side: the MenuPopover has maxHeight added by autoSize. But MenuList can still overflow MenuPopover even when it has style height: 100%. This is because height percentage is based on the height value of the parent element, but the parent MenuPopover has only maxHeight.

New Behavior

Screenshot 2023-07-24 at 14 37 49

The changes:

  1. In autoSize modifier, add height/width when overflow happens. Set overflowX/overflowY to auto only when overflow happens.
  2. Set height: 100% on MenuList when it is inside Menu context.

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 24, 2023

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-combobox
Combobox (including child components)
87.199 kB
28.143 kB
87.395 kB
28.184 kB
196 B
41 B
react-combobox
Dropdown (including child components)
85.602 kB
27.746 kB
85.798 kB
27.804 kB
196 B
58 B
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
213.111 kB
59.12 kB
207.472 kB
57.814 kB
-5.639 kB
-1.306 kB
react-datepicker-compat
DatePicker Compat
223.394 kB
59.277 kB
217.582 kB
58.025 kB
-5.812 kB
-1.252 kB
react-infobutton
InfoButton
131.361 kB
40.326 kB
126.163 kB
39.164 kB
-5.198 kB
-1.162 kB
react-infobutton
InfoLabel
134.966 kB
41.462 kB
129.763 kB
40.304 kB
-5.203 kB
-1.158 kB
react-menu
Menu (including children components)
132.703 kB
40.62 kB
135.5 kB
41.325 kB
2.797 kB
705 B
react-menu
Menu (including selectable components)
135.467 kB
41.115 kB
138.264 kB
41.828 kB
2.797 kB
713 B
react-popover
Popover
119.925 kB
36.895 kB
114.722 kB
35.751 kB
-5.203 kB
-1.144 kB
react-positioning
usePositioning
24.272 kB
8.866 kB
24.468 kB
8.915 kB
196 B
49 B
react-table
DataGrid
158.216 kB
42.389 kB
158.464 kB
42.465 kB
248 B
76 B
react-table
Table as DataGrid
132.019 kB
33.82 kB
132.268 kB
33.902 kB
249 B
82 B
react-tags-preview
TagGroup
69.142 kB
20.294 kB
69.398 kB
20.364 kB
256 B
70 B
react-tooltip
Tooltip
47.463 kB
16.655 kB
47.659 kB
16.697 kB
196 B
42 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-alert
Alert
84.992 kB
22.03 kB
react-avatar
Avatar
47.739 kB
14.521 kB
react-avatar
AvatarGroup
15.695 kB
6.314 kB
react-avatar
AvatarGroupItem
63.915 kB
19.001 kB
react-components
react-components: Button, FluentProvider & webLightTheme
67.576 kB
18.225 kB
react-components
react-components: FluentProvider & webLightTheme
36.409 kB
12.003 kB
react-persona
Persona
55.293 kB
16.535 kB
react-portal-compat
PortalCompatProvider
6.48 kB
2.203 kB
react-table
Table (Primitives only)
43.95 kB
12.263 kB
react-table
Table (Selection only)
77.643 kB
19.195 kB
react-table
Table (Sort only)
76.262 kB
18.798 kB
react-tags-preview
InteractionTag
34.171 kB
9.199 kB
react-tags-preview
Tag
25.962 kB
8.49 kB
🤖 This report was generated against 0d4d0ef8daebaf5b6ebbcce17e64e35488864e0e

@YuanboXue-Amber YuanboXue-Amber changed the title Fix: menu feat(react-menu, react-positioning): update maxSize to prevent double scrollbar for Menu in small viewport Jul 24, 2023
@fabricteam
Copy link
Collaborator

fabricteam commented Jul 24, 2023

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 600 584 5000
Button mount 304 299 5000
Field mount 1063 1045 5000
FluentProvider mount 630 641 5000
FluentProviderWithTheme mount 73 68 10
FluentProviderWithTheme virtual-rerender 62 61 10
FluentProviderWithTheme virtual-rerender-with-unmount 69 71 10
InfoButton mount 11 13 5000
MakeStyles mount 859 848 50000
Persona mount 1644 1608 5000
SpinButton mount 1337 1295 5000

@YuanboXue-Amber YuanboXue-Amber marked this pull request as ready for review July 24, 2023 14:10
@YuanboXue-Amber YuanboXue-Amber requested review from a team as code owners July 24, 2023 14:10
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 24, 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 3789163:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration
charming-kepler-q8wkkj PR

@size-auditor
Copy link

size-auditor bot commented Jul 24, 2023

Asset size changes

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

Baseline commit: e7e522f452c4090c7f4426082efac571e8141a8e (build)

@YuanboXue-Amber
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

No commit pushedDate could be found for PR 28622 in repo microsoft/fluentui

@YuanboXue-Amber YuanboXue-Amber enabled auto-merge (squash) July 25, 2023 12:37
@YuanboXue-Amber YuanboXue-Amber merged commit e59b4b3 into microsoft:master Jul 25, 2023
@YuanboXue-Amber YuanboXue-Amber deleted the maxsize-height branch July 25, 2023 15:38
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