Skip to content

Long option causes menu to open in wrong position issue #837

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

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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