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

Add "size" popover middleware to fix overflow issues in Popover.Dropdown #5213

Merged
merged 2 commits into from Nov 7, 2023

Conversation

ranquild
Copy link
Contributor

@ranquild ranquild commented Nov 7, 2023

Currently, if the Popover.Dropdown content is tall, there is no way to add scrollbars (overflow) properly as the dropdown overflows the page. Reproduction https://codesandbox.io/s/amazing-nobel-s6zqy8

This issue is supposed to be fixed by size middleware in floating-ui. This PR fixes the issue by adding size option in PopoverMiddlewares which enables the size middleware, which in turn uses availableWidth and availableHeight per floating-ui docs.

I decided not to set overflow: auto automatically in Popover.Dropdown because in some places there might be a requirement to shrink the content and not to add scrollbars.

How to verify:

Issue (codesandbox):
Screenshot 2023-11-07 at 12 43 33

Fix (storybook):
Screenshot 2023-11-07 at 12 32 46

placement: options.position,
middleware: [
...getPopoverMiddlewares(options),
...(options.width === 'target'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to getPopoverMiddlewares

@@ -74,22 +102,9 @@ export function usePopover(options: UsePopoverOptions) {
}
};

const floating = useFloating({
const floating: UseFloatingReturn<Element> = useFloating({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an explicit type TS throws an error

@rtivital rtivital merged commit 0406943 into mantinedev:master Nov 7, 2023
1 check passed
@rtivital
Copy link
Member

rtivital commented Nov 7, 2023

Thanks!

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.

None yet

2 participants