-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(useFloating): avoid setting isPositioned to true when open is false
#3042
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
Conversation
🦋 Changeset detectedLatest commit: 8199f19 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for vibrant-gates-22c214 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Are you sure that this did not break what is documented here? isPositioned is no longer changing |
It works locally just fine, which means you might be experiencing an edge case where you were relying on the old behavior in some scenario. The only thing I can think of is Can you provide a reproduction where it fails? |
|
Okay, I know where it can fail, but it seems to highlight improper usage. It can happen when combining these usage scenarios:
I would say this isn’t technically a regression but rather a bug fix that caused code relying on the old behavior to unfortunately start breaking unexpectedly (something semver isn't capable of handling). However it actually highlights an issue in the consumer code because the positioning wasn’t implemented correctly before. When not using conditional rendering, this is the correct way to use useLayoutEffect(() => {
if (open && elements.reference && elements.floating) {
return autoUpdate(elements.reference, elements.floating, update);
}
}, [elements.reference, elements.floating, open, update]);Or at the very least, when not using useLayoutEffect(() => {
if (open) {
update();
}
}, [open, update]);This not only makes |
|
@atomiks Thanks for clarifying. When not using conditional rendering tho if open is set to true and then false, would you expect to have isPositioned as |
|
Yes because even though it was already positioned and remains mounted, the position can become "stale" while it's closed. It's possible that the next open has a drastically different position where you'll need to wait for |
|
ok this is weird to me and it was not like this before (if it was a bug or not whatever) To me it should return |
#3017 (comment)