-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Popover: Allow legitimate 0 positions to update popover position #51320
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0ea42d0
Popover: Allow legitmate 0 positions to update popover position
andrewserong f81f2ad
Add changelog entry
andrewserong 86fb707
Refactor to utility function
ciampo 50475b5
Add unit tests
ciampo 463041f
Switch to undefined fallback for null and NaN cases, update snapshots
andrewserong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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.
On second thoughts, perhaps this side of the ternary should be
undefined
as prior to this PR, the||
meant that nullish orNaN
values resulted inundefined
... I can give that a try tomorrow, as that might potentially resolve the issue with the failing snapshot tests.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.
To sum up, here are the different versions for this algorithm tried so far:
c === null || Number.isNaN( c ) ? 0 : Math.round( c )
Math.round( c ?? 0 ) || undefined
Number.isNaN( c ) ? 0 : c ?? undefined
I guess we need to understand exactly in which scenario we'd need to have
undefined
instead of0
. @corentin-gautier maybe can also help, since he worked on #46187 ?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.
Thanks for outlining each of the different options. To try to be more conservative about it, I've updated this logic in this PR to
c === null || Number.isNaN( c ) ? undefined : Math.round( c )
so that we're only outputting a number when we have a real value. I think that might get us to a smaller potential change? Happy to revert if need be.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.
That looks good to me. Looking at the snapshot changes, it's interesting that motion stops applying a transform on the
Z
axis — it must be some internal framer motion optimisation. From past experience, usually the reason for havingtranslateZ(0)
would be to promote an element to a separate composite layer, thus reducing the amount of times it needs to be re-painted to screen. But I can see that we're already applying thewill-change: transform
style, which also achieves the same goal, so we should also be fine under that point of view.