fix: show the loading placeholder while a doc's tree is fetched - #342
Open
iftakharul-islam wants to merge 1 commit into
Open
iftakharul-islam wants to merge 1 commit into
iftakharul-islam wants to merge 1 commit into
Conversation
Opening a documentation rendered a blank screen until its sections arrived, then filled in with no transition. The listing screen gated its placeholder on the store's `loading` flag, which belongs to the dashboard's own request and is false while a doc's branch is being fetched, so the empty state rendered for the whole of that request. Gate on this screen's own readiness instead: the dashboard request, the child request, and whether the branch has been loaded at all. The section and article selectors also subscribed with an empty dependency list, so they kept returning the value captured on first render and only updated when something else happened to re-render. That is what made the content appear late rather than as soon as it arrived. loadDocTree now marks a branch loaded whenever the request succeeds rather than only when it returns sections, so a documentation with no sections shows its empty state instead of waiting forever, and the effect tracks the ID it requested so a failed fetch cannot become a request loop. Refs weDevsOfficial/wedocs-pro#366
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.
Follow-up to #340 (already merged). Fixes a UX regression that came in with the lazy loading.
Tracking issue: weDevsOfficial/wedocs-pro#366
Symptom
Opening a documentation showed a blank screen first, then everything appeared at once with no transition — no skeleton, no animation.
Why
Three things, all introduced or exposed by the lazy loading in #340.
1. The placeholder was gated on the wrong flag.
DocListingused the store'sloading, which tracks the dashboard's request. During a doc's own child fetch that flag isfalse, so! loadingwas true and the component rendered its "No section or article found" branch for the entire request.2. The selectors were not subscribed.
getSectionsDocsandgetDocArticleswere called with an empty dependency list:so they kept returning the value captured on first render and only refreshed when something unrelated forced a re-render. That is what made content arrive late rather than as soon as the fetch resolved.
3. A doc with no sections would wait forever.
loadDocTreeonly calledmarkChildrenLoadedwhensections.lengthwas truthy — a guard I added in #340 to make failed requests retry. But that conflates "request failed" with "this doc genuinely has no sections", so an empty documentation never becamechildrenLoaded.Changes
docsLoading || loadingChildren || ! childrenLoaded[ id, docs ]) so they track the storetry/finallysoloadingChildrenalways clears; a genuine failure stays unmarked and retriesVerification
Loading gate checked across every transition:
loadingtruetruefalsefalsetruefalseConfirmed against the live API that the empty case returns HTTP 200 with 0 sections, so it now marks loaded and shows its empty state rather than waiting forever.
Build and
no-undeflint clean.Not yet visually confirmed in a browser — the Playwright profile was locked by a running Chrome instance while I was working, so the skeleton itself has not been seen on screen. The state logic is verified as above, but a quick manual check of the skeleton appearing on a slow doc would be worth doing before merge.