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

fix(useOverlay): Only enable maxSize modifier when open #43193

Merged
merged 3 commits into from
Jan 13, 2023

Conversation

vuluongj20
Copy link
Member

Currently, the maxSize modifier is always enabled. This means PopperJS is always listening to scroll events and updating the overlay's max width/height, even if the menu is closed, which is wasteful. This PR disables maxSize when the open state is false.

Before: the overlay's max-height is updated regardless of the menu's open state
https://user-images.githubusercontent.com/44172267/212171989-bdd51d23-ec17-4213-8144-353e6ea0ad6b.mov

After: the overlay's max-height is only updated when the menu of open
https://user-images.githubusercontent.com/44172267/212172031-31eb8091-8e36-40c6-b36e-d2c3727e0080.mov

There is no change in behavior — overlays will still scroll to prevent overflow:
https://user-images.githubusercontent.com/44172267/212173349-aaf55aa5-1da2-459c-b4d7-171f37ba2597.mov

@vuluongj20 vuluongj20 requested a review from a team January 12, 2023 20:26
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 12, 2023
phase: 'main',
requiresIfExists: ['offset', 'preventOverflow', 'flip'],
enabled: false, // will be enabled when overlay is open
Copy link
Member Author

Choose a reason for hiding this comment

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

This still needs to be defined to satisfy the Modifier type

Comment on lines 106 to 115
// Initialize open state
const openState = useOverlayTriggerState({
isOpen,
defaultOpen,
onOpenChange: open => {
onOpenChange?.(open);
open && popperUpdate?.();
},
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Moving this up so we can use it in modifiers

@vuluongj20 vuluongj20 merged commit fb815f4 into master Jan 13, 2023
@vuluongj20 vuluongj20 deleted the vl/use-overlay-max-size-disable branch January 13, 2023 22:55
DominikB2014 pushed a commit that referenced this pull request Jan 16, 2023
Currently, the `maxSize` modifier is always enabled. This means PopperJS
is always listening to scroll events and updating the overlay's max
width/height, even if the menu is closed, which is wasteful. This PR
disables `maxSize` when the open state is false.

**Before:** the overlay's `max-height` is updated regardless of the
menu's open state

https://user-images.githubusercontent.com/44172267/212171989-bdd51d23-ec17-4213-8144-353e6ea0ad6b.mov

**After:** the overlay's max-height is only updated when the menu of
open

https://user-images.githubusercontent.com/44172267/212172031-31eb8091-8e36-40c6-b36e-d2c3727e0080.mov

**There is no change in behavior** — overlays will still scroll to
prevent overflow:

https://user-images.githubusercontent.com/44172267/212173349-aaf55aa5-1da2-459c-b4d7-171f37ba2597.mov
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants