[ui] Directly set MiddleTruncate truncated text to fix flicker #26888
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.
Summary & Motivation
This is a small follow-up to #26834
I've noticed that sometimes with MiddleTruncate, there is a very slight flicker when the text is first rendered. There's a single frame where the rendered text is
null
, and you can see it before the text appears.I'm not sure if my computer is just running slow today (looking for excuses to get an M4 now...), or if it's the volume of MiddleTruncates on this page (there are at least 50 rendering all at the same time), but here's an example if you watch the tag on the right:
text-flicker.mov
Looking at the code for this, I don't think there's a reason for the sizing to update React state and set the text through a React render. The text is just used to set the span content, and the component doesn't re-render unless the text changes (in which case
calculateTargetStyle
changes and the effect runs again.) Setting the textContent directly removes the flicker shown in the video.How I Tested These Changes
Tested in FF + Chrome manually