-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Migrate TooltipRenderedOnPageBody and fix tooltip flicker/moving when the content changes #18189
Conversation
@amyevans @mananjadhav One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Turns out there are more changes than expected. Here is the explanation of the changes: To prevent the tooltip flickering/moving, we use Besides migrating it, there are also some logic changes to the component, mainly the Before: Now: (because we set all value initially to their "default", we don't need this workaround anymore that fixed this issue) text changes -> rerender -> update tooltipContentWidth to undefined -> rerender -> calculate new position -> rerender In order to solve it, I use Last thing, I just realized that tooltip with custom component content could also changes, for example the reaction tooltip (the only custom tooltip). Here is a recording on Screen.Recording.2023-04-29.at.16.56.41.movSo, to solve it, I introduce a new props called In short, we follow the same step as mentioned in the doc). When the text changes, we remount the component which will repeat the exact steps from the doc It's quite hard to explain it all with words, so please ask if there is anything confusing 😄. |
Here is additional video to show the tooltip still works fine on other components: Screen.Recording.2023-04-29.at.18.20.03.mov=== Btw, I notice that currently (on prod), the tooltip won't move if the wrapped component width increase/decrease. If we care about that, I think we can create a new issue to investigate it (it's because the wrapped component width is not updated, but I guess it needs quite a lot changes too, so I leave it as it is) Screen.Recording.2023-04-29.at.19.04.37.mov |
@bernhardoj I understood the changes and thanks for updating this, turned out really well. I am just a bit concerned about the type here Testing now. |
Reviewer Checklist
Screenshots/VideosWebweb-tooltip-func.movweb-safari-tooltip-func_pz9Vx3zR.mp4Mobile Web - Chrome-NA- Mobile Web - Safari-NA- Desktopdesktop-tooltip-func.moviOS-NA- Android-NA- Thanks for the patience here @bernhardoj. I had to test this on Web Chrome and Safari both and Desktop. @amyevans All yours. |
@mananjadhav thanks for the review.
Hmm yeah, maybe we can make it specific to one of string, number, or bool?
From my testing, |
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.
Looking good!
Manan is offline and previously approved, so I'm going to proceed and merge! |
🚀 Deployed to staging by https://github.com/amyevans in version: 1.3.12-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.12-0 🚀
|
🚀 Deployed to staging by https://github.com/amyevans in version: 1.3.12-0 🚀
|
|
||
// We pass a key, so whenever the content changes this component will completely remount with a fresh state. | ||
// This prevents flickering/moving while remaining performant. | ||
key={[this.props.text, ...this.props.renderTooltipContentKey]} |
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 line caused a regression in #19693 , Using a key will trigger the view to re-render when the text changes. However, if the text changes before the animation finishes, it will cancel the animation, and the tooltip will disappear. More context
}, [props.text, props.renderTooltipContent]); | ||
|
||
useLayoutEffect(() => { | ||
// Calculate the tooltip width and height before the browser repaints the screen to prevent flicker |
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.
Coming from #48691, we had an issue where the tooltip displays as blank. This happens because the tooltip component gets frozen when navigating several screens away and then back and when this effect is called a second time, the size is calculated as 0 due to the animation effect scale(0)
. More details here.
Details
The main goal of the PR is to fix the flickering of the tooltip when the content changes. To achieve it, we need to use
useLayoutEffect
which is only available on functional component, thus the migration is also done here.Fixed Issues
$ #17555
PROPOSAL: #17555 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Android/iOS/mWeb
No tooltip on these platforms
Web/Desktop
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-04-29.at.18.19.16.mov
Mobile Web - Chrome
No Tooltip
Mobile Web - Safari
No Tooltip
Desktop
Screen.Recording.2023-04-29.at.18.24.10.mov
iOS
No Tooltip
Android
No Tooltip