fix(canary-web-components): update tree view to improve FOUC #3154
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 of the changes
Updated tree view to improve FOUC. Click between the different tree view stories to see that the flashing is now reduced (also improved for on whole page reload / refresh).
Added
visibility: hidden
to certain elements until they have fully loaded. Means there is still a kind of flashing but I feel it looks nicer than elements moving about?Removing the truncation timeouts has helped improve the flashing slightly I think - truncation is now applied as soon as the tree view is fully loaded rather than waiting 0.1 seconds.
Without the timeouts, however, I was sometimes getting an issue where the heading wouldn't truncate. I've added padding-right while the component hydrates as this accounts for the change in text width, which was affecting the scrollHeight check on line 271 because the text wasn't wrapping onto two lines between initial page load and hydration.
I've updated the unit test snapshots - includes some changes from previous PRs; think they had become a bit out of sync due to us not being able to run unit tests in canary.
Related issue
#2863
Checklist
General
Testing
Accessibility
Resize/zoom behaviour
System modes
Testing content extremes