Repository navigation
Stop the page moving while charts load, and keep pages steady when moving between them (fix #509) - #511
Merged
Conversation
Each metric rendered nothing until its data arrived, then a spinner the height of a few dots until its chart code arrived, so every chart that loaded pushed the rest of the page down. Summary bars also rendered nothing while loading, and collapsed again on every region change. Pending metrics and summary bars now render a placeholder the size of what replaces them, and the spinner while the chart code loads takes the chart's size. Only descriptions and legends, whose height isn't known until the data arrives, still move what's below them.
On short pages like Contact and Not Found, the footer sat just below the content, part way up the window. The page is now a column at least as tall as the window, with main taking the spare height. While a dashboard loads, main is also at least as tall as the window, so the footer stays out of sight instead of jumping off the screen when the dashboard arrives. That jump was the largest layout shift left on every dashboard. The gap above the header moves from a relative offset to padding, so that it counts toward the page's height instead of making every page scroll by it.
Moving between pages flickered through spinners and placeholders even on a return visit. Main and MetricOverview created a new React.lazy on every mount, which suspends once even when its code has loaded, and withFetch fetched every response again, with the CDN forcing max-age=0. lazyLoad now renders loaded code straight away, and the lazy components are created once. withFetch keeps responses until the page reloads and shares one request between components asking for the same URL, which hardware's summary bars and metrics do. A chunk that fails to load is no longer loaded again on the next visit. Browsers can keep a failed import() too, so that retry wasn't reliable; the error now offers a page reload instead.
BrowserRouter leaves the window scrolled where it was. Now that a page visited before renders at full height at once, the Next button opened it part way down in Firefox and Safari. Back and forward still keep the browser's own scroll restoration.
After a client-side navigation, focus stayed on the header link, or fell to the body when the Next button that had it was replaced, and screen readers weren't told that a new page had loaded. Focus now moves to the page's heading, as a full page load would start at the top, so a screen reader reads it and Tab continues from there. Back and forward keep their scroll position. Until a dashboard's heading arrives, main holds focus, and the heading takes it unless the reader has moved on. The route and dashboard spinners now tell screen readers they're loading, once the dots appear, and Not Found has its own title instead of the previous page's.
An unknown URL under /dashboard/ took the dashboards' full-height layout, pushing its Not Found page's footer below the window. The layout now applies only to configured dashboards, matched as the routes match them. The chart and table code started loading on every page, because MetricOverview comes with the dashboard page's code, which every page starts loading. lazyLoad can now defer loading until first render, and MetricOverview's components do. When a page's code failed to load after navigating, focus stayed on main and the error wasn't announced. The route-level error heading now takes focus as a page heading does. Moving from a request in flight or failed to a URL whose cached response was empty left the component pending or rejected, as both have no value. It now updates whenever it isn't already fulfilled.
Deferring the chart and table code until a metric renders saved a download only for visitors who never open a dashboard, which is few, and brought back the wait on a first dashboard visit: the chart code started loading only once the metric's data had arrived. Starting it with the dashboard page's code, which every page loads, means it is usually ready before the data is.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Route-wide focus management and live-region announcements require outstanding human VoiceOver/Safari validation, including heading and loading announcements during Back navigation.
3 resolved since last review
Review effort: Balanced
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Fixes #509.
Each metric used to render nothing while its data loaded, so every chart that arrived pushed the rest of the page down. Fixing that showed the same problem when moving between pages, so this also covers the rest of the browsing experience. Each commit stands alone and passes lint and tests.
withFetchkeeps responses until the page reloads, and components asking for the same URL share one request.import(), so the old retry on the next visit wasn't reliable.Layout shift on first load, measured with data delayed 200–800ms:
Testing:
fixtures/placeholders.spec.js: each placeholder takes the space of what replaces it, and the footer stays out of sight while a dashboard loads.fixtures/navigation.spec.js: revisits show no loading states and make no data requests, the Next button opens pages at the top, and focus lands on the right element after each kind of navigation.footer.spec.jsnow checks that short pages put the footer at the bottom of the window.lazyLoad, the spinner's status text, page views across navigation, and the Not Found title.