Skip to content
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

fix(canary-web-components): update tree view to improve FOUC #3154

Merged

Conversation

GCHQ-Developer-847
Copy link
Contributor

@GCHQ-Developer-847 GCHQ-Developer-847 commented Feb 7, 2025

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

  • Changes to docs package checked and committed.
  • All acceptance criteria reviewed and met.

Testing

  • Relevant unit tests and visual regression tests added.
  • Visual testing against Figma component specification completed.
  • Playground stories in React Storybook up to date, with any prop changes and additions addressed.
  • Compare performance of modified components against develop using Performance addon in React Storybook.

Accessibility

  • Accessibility Insights FastPass performed.
  • A11y unit test added and yields no issues.
  • A11y plug-in on Storybook yields no issues.
  • Manual screen reader testing performed using NVDA and VoiceOver.
  • Manual keyboard testing for keyboard controls and logical focus order.
  • Correct roles used and ARIA attributes used correctly where required.
  • Logical heading structure is maintained, and the HTML elements used for headings can be changed to fit within the wider page structure.

Resize/zoom behaviour

  • Page can be zoomed to 400% with no loss of content.
  • Screen magnifier used with no issues.
  • Text resized to 200% with no loss of content.
  • Text spacing increased as per the WCAG 1.4.12 success criterion with no loss of content.

System modes

  • Browser setting 'prefers reduced motion' tested. No animations or motion visible whilst this setting is on.
  • Windows High Contrast mode tested with no loss of content.
  • System light and dark mode tested with no loss of content.
  • Browser support tested (Chrome, Safari, Firefox and Edge).

Testing content extremes

  • Min/max content examples tested with no loss of content or overflow.
  • All prop combinations work without issue.
  • Tested for FOUC (Flash of Unstyled Content) in both SSR (Server-Side Rendering) and SSG (Static Site Generation) settings.
  • Controlled and uncontrolled input components tested.
  • Props/slots can be updated after initial render.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

@GCHQ-Developer-847 GCHQ-Developer-847 force-pushed the fix/2863-tree-view-flashing-on-load branch from 6c26721 to ba031da Compare February 7, 2025 15:45
@GCHQ-Developer-847 GCHQ-Developer-847 marked this pull request as ready for review February 7, 2025 16:19
Update tree view to prevent FOUC - set tree items visibility to hidden until loaded when inherited
props from tree view used. Removed timeouts on truncation - tree view now truncates when ready
rather than waiting 0.1 seconds to help reduce flashing.
…d items

Update tree view truncation story to have expanded items - to show truncation working on nesting
items.
@GCHQ-Developer-847 GCHQ-Developer-847 force-pushed the fix/2863-tree-view-flashing-on-load branch from ba031da to 2c6546c Compare February 7, 2025 16:40
@GCHQ-Developer-847 GCHQ-Developer-847 merged commit 6fffeeb into v3.0.0/develop Feb 11, 2025
6 checks passed
@GCHQ-Developer-847 GCHQ-Developer-847 deleted the fix/2863-tree-view-flashing-on-load branch February 11, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants