Fix full screen loading indicator when routes are loaded lazy (or components uses React.Suspense) #9297
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:
https://issues.redhat.com/browse/ODC-5633
Analysis / Root cause:
When switching on the Pod detail page to the "Terminal" tab a lazy route / AsyncComponent was loaded and the user saw for a moment (depending on your internet speed) a strange full screen loading indicator.
This flicking happen because this loading uses react suspense and we have only one
<React.Suspense />
at the application root level (app.jsx). This catch components works similar to ErrorBoundaries and could be used on different application levels.Solution Description:
Wrap the page content and horizontal navigation tab content also with a
<React.Suspense />
component.This ensures that AsyncComponent loading on this levels shows a better loading indicator only in the content area. This would work also for other suspense usages.
I tested this by adding temporary suspense component to
PodExecLoader
(which us used in the terminal tab):Screen shots / Gifs for design review:
The original issue force with throttled internet connection:
Added the
Delay
component above toPodExecLoader
without any other change:When wrapping the page content (react router Switch) just in
app-contents.tsx
:This helps for all pages without horizontal nav. But the navigation goes away and come back after the
suspense
promise is resolved.When wrapping also the tab content (react router Switch again) in
horizontal-nav.tsx
:This fixes the issue that the tab navigation goes way and come back after the
suspense
promise is resolved.Unit test coverage report:
Unchanged
Test setup:
Better testable on a cluster or with throttled internet connection.
Browser conformance: