-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-menu, react-positioning): update maxSize to prevent double…
… scrollbar for Menu in small viewport (#28622) * fix * conditional overflowy * upd * chg * api * use overflow scroll in test * f * scroll->auto
- Loading branch information
1 parent
c0c62f9
commit e59b4b3
Showing
10 changed files
with
137 additions
and
21 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
apps/vr-tests-react-components/src/stories/Menu/ScrollableMenuSmallViewport.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import * as React from 'react'; | ||
|
||
import { Menu, MenuTrigger, MenuList, MenuItem, MenuPopover, MenuGroup, MenuDivider } from '@fluentui/react-menu'; | ||
import { makeStyles, shorthands } from '@griffel/react'; | ||
import { PositioningProps } from '@fluentui/react-positioning'; | ||
import { Steps, StoryWright } from 'storywright'; | ||
const useStyles = makeStyles({ | ||
wrapper: { display: 'flex' }, | ||
shortContainer: { | ||
width: '200px', | ||
height: '220px', | ||
...shorthands.border('2px', 'dashed', 'red'), | ||
...shorthands.padding('10px'), | ||
}, | ||
longContainer: { | ||
width: '200px', | ||
height: '400px', | ||
...shorthands.border('2px', 'dashed', 'green'), | ||
...shorthands.padding('10px'), | ||
}, | ||
scrollableMenuGroup: { | ||
maxHeight: '150px', | ||
overflowY: 'auto', | ||
}, | ||
menuPopover: { | ||
overflowX: 'hidden', | ||
}, | ||
}); | ||
|
||
const ScrollableMenu = ({ overflowBoundary }: Pick<PositioningProps, 'overflowBoundary'>) => { | ||
const styles = useStyles(); | ||
return ( | ||
<Menu open positioning={{ overflowBoundary, flipBoundary: overflowBoundary, autoSize: true }}> | ||
<MenuTrigger disableButtonEnhancement> | ||
<button>Menu</button> | ||
</MenuTrigger> | ||
|
||
<MenuPopover className={styles.menuPopover}> | ||
<MenuList> | ||
<MenuGroup className={styles.scrollableMenuGroup}> | ||
<MenuItem>Cut</MenuItem> | ||
<MenuItem>Paste</MenuItem> | ||
<MenuItem>Edit</MenuItem> | ||
<MenuItem>Undo</MenuItem> | ||
<MenuItem>Redo</MenuItem> | ||
<MenuItem disabled>Open File</MenuItem> | ||
<MenuItem>Open Folder</MenuItem> | ||
</MenuGroup> | ||
<MenuDivider /> | ||
<MenuItem>New </MenuItem> | ||
<MenuItem>New Window</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
); | ||
}; | ||
|
||
const Example = () => { | ||
const styles = useStyles(); | ||
const [shortOverflowBoundary, setShortOverflowBoundary] = React.useState<HTMLElement | null>(null); | ||
const [longOverflowBoundary, setLongOverflowBoundary] = React.useState<HTMLElement | null>(null); | ||
|
||
return ( | ||
<StoryWright steps={steps}> | ||
<div className={styles.wrapper}> | ||
<div className={styles.shortContainer} ref={setShortOverflowBoundary}> | ||
<div>Short viewport:</div> | ||
<ScrollableMenu overflowBoundary={shortOverflowBoundary} /> | ||
</div> | ||
|
||
<div className={styles.longContainer} ref={setLongOverflowBoundary}> | ||
<div>Long viewport:</div> | ||
<ScrollableMenu overflowBoundary={longOverflowBoundary} /> | ||
</div> | ||
</div> | ||
</StoryWright> | ||
); | ||
}; | ||
|
||
const steps = new Steps().snapshot('default').end(); | ||
export const ScrollableMenuSmallViewport = () => ( | ||
<StoryWright steps={steps}> | ||
<Example /> | ||
</StoryWright> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-menu-03f8268f-d187-4f13-ac82-48548dfa3c97.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "feat: update style to prevent double scrollbar", | ||
"packageName": "@fluentui/react-menu", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-positioning-f6515d84-5f8b-4649-90dc-7d0cf179d176.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "feat: update maxSize middleware to apply height/width when overflow", | ||
"packageName": "@fluentui/react-positioning", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters