Skip to content

Commit 31b1802

Browse files
Long option causes menu to open in wrong position issue (#837)
* Long option causes menu to open in wrong position issue * updated the test file
1 parent 702415a commit 31b1802

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/Overlay/Overlay.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ describe('Overlay modifiers', () => {
9999
const props: ModifierProps = { align: 'justify', flip: false };
100100

101101
const modifiers = getModifiers(props);
102-
expect(modifiers).toHaveLength(2);
102+
expect(modifiers).toHaveLength(3);
103103
expect(
104104
modifiers.find(({ name }) => name === 'setPopperWidth')
105105
).toBeTruthy();
106106

107107
props.align = 'left';
108-
expect(getModifiers(props)).toHaveLength(1);
108+
expect(getModifiers(props)).toHaveLength(2);
109109

110110
props.align = 'right';
111-
expect(getModifiers(props)).toHaveLength(1);
111+
expect(getModifiers(props)).toHaveLength(2);
112112
});
113113
});

src/components/Overlay/useOverlay.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export function getModifiers(props: Pick<OverlayOptions, 'align' | 'flip'>) {
2929
enabled: !!props.flip,
3030
name: 'flip',
3131
},
32+
{
33+
name: 'preventOverflow',
34+
options: {
35+
mainAxis: false
36+
}
37+
}
3238
];
3339

3440
if (props.align !== 'right' && props.align !== 'left') {
@@ -63,7 +69,7 @@ export function useOverlay(
6369
);
6470

6571
const refElementHeight = referenceElement?.offsetHeight;
66-
72+
6773
// Re-position the popper if the height of the reference element changes.
6874
// Exclude `forceUpdate` from dependencies since it changes with each render.
6975
useEffect(() => {

0 commit comments

Comments
 (0)