Skip to content

Commit

Permalink
Long option causes menu to open in wrong position issue (#837)
Browse files Browse the repository at this point in the history
* Long option causes menu to open in wrong position issue
* updated the test file
  • Loading branch information
Nathan-Roberts123 authored Nov 28, 2024
1 parent 702415a commit 31b1802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/Overlay/Overlay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ describe('Overlay modifiers', () => {
const props: ModifierProps = { align: 'justify', flip: false };

const modifiers = getModifiers(props);
expect(modifiers).toHaveLength(2);
expect(modifiers).toHaveLength(3);
expect(
modifiers.find(({ name }) => name === 'setPopperWidth')
).toBeTruthy();

props.align = 'left';
expect(getModifiers(props)).toHaveLength(1);
expect(getModifiers(props)).toHaveLength(2);

props.align = 'right';
expect(getModifiers(props)).toHaveLength(1);
expect(getModifiers(props)).toHaveLength(2);
});
});
8 changes: 7 additions & 1 deletion src/components/Overlay/useOverlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export function getModifiers(props: Pick<OverlayOptions, 'align' | 'flip'>) {
enabled: !!props.flip,
name: 'flip',
},
{
name: 'preventOverflow',
options: {
mainAxis: false
}
}
];

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

const refElementHeight = referenceElement?.offsetHeight;

// Re-position the popper if the height of the reference element changes.
// Exclude `forceUpdate` from dependencies since it changes with each render.
useEffect(() => {
Expand Down

0 comments on commit 31b1802

Please sign in to comment.