-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
Scope: Frontend
Automatically applied to PRs that change frontend components
label
Jan 12, 2023
vuluongj20
commented
Jan 12, 2023
phase: 'main', | ||
requiresIfExists: ['offset', 'preventOverflow', 'flip'], | ||
enabled: false, // will be enabled when overlay is open |
There was a problem hiding this comment.
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
vuluongj20
commented
Jan 12, 2023
static/app/utils/useOverlay.tsx
Outdated
Comment on lines
106
to
115
// Initialize open state | ||
const openState = useOverlayTriggerState({ | ||
isOpen, | ||
defaultOpen, | ||
onOpenChange: open => { | ||
onOpenChange?.(open); | ||
open && popperUpdate?.(); | ||
}, | ||
}); | ||
|
There was a problem hiding this comment.
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
malwilley
approved these changes
Jan 13, 2023
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 disablesmaxSize
when the open state is false.Before: the overlay's
max-height
is updated regardless of the menu's open statehttps://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