Bugfix: Resolve Page Cache Inconsistency on Navigation #67
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.
🔧 Bugfix: Resolve Page Cache Inconsistency on Navigation
📌 Summary
This PR addresses an issue where stale or incorrect layout state could persist across page transitions in the Unified Page Renderer, resulting in inconsistent or incorrect rendering of layouts and modules when navigating between pages.
🐞 Problem
currentLayoutswas empty, causing stale or cross-page layout states to be applied incorrectly.UnifiedPageRenderercomponent was not resetting internal state cleanly between page transitions, exacerbating the caching problem.✅ Solution
State Validation in
LayoutEngineLayoutEngine.tsxto prefercurrentLayoutsif it is empty andcommittedLayoutsis not, preventing stale layouts from being reused.isEmptyLayouts()utility to check all breakpoints (mobile,tablet,desktop,wide,ultrawide) for emptiness.State Isolation in
UnifiedPageRendererkeyprop to theLayoutEngineusingpageData.id || pageId || routeto ensure reactive re-rendering of the layout engine when navigating to a new page.Stricter Reset in
useUnifiedLayoutStateImproved
resetLayouts()to:committedLayoutsRefandlastCommittedVersionRef.layoutChangeManagerRef.layoutCommitTracker.This ensures full isolation of layout state per page.
🧪 Test Coverage
Manually verified page navigation across multiple routes to confirm:
LayoutEnginere-initialization on route change🗂️ Affected Files
LayoutEngine.tsx— Updated layout decision logic and helperUnifiedPageRenderer.tsx— Addedkeyto force component remountuseUnifiedLayoutState.ts— Hardened reset behavior