-
由 wwwillchen-bot 提交于
## Summary - Changed `navigateToRoute()` to use `postMessage` + `location.replace()` pattern instead of direct `location.href` assignment - This matches the approach used by back/forward navigation buttons and provides smooth navigation without the black screen flicker and sidebar state reset - Also added proper `currentIframeUrlRef` and `preservedUrls` updates for HMR remount consistency Fixes #2428 ## Test plan - [x] Build succeeds - [x] Unit tests pass (784 tests) - [x] E2E tests pass for preview navigation (`npm run e2e -- --grep "preview navigation"`) - Manual testing: Open a multi-page app, use the route dropdown to navigate between routes - should no longer see black screen flicker or sidebar collapse
🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2610" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes #2428: removes black screen flicker and sidebar collapse when selecting routes from the preview dropdown. Navigation now uses postMessage + location.replace and keeps the iframe src stable across SPA navigation and HMR. - **Bug Fixes** - Use postMessage + location.replace to navigate; prevents flicker and preserves sidebar state. - Freeze iframe src with useMemo and same-origin check so SPA nav/HMR don’t reset it; added e2e test to verify src remains unchanged. - Sync navigation state: history, canGoBack/canGoForward, currentIframeUrlRef, and per-app preservedUrls (clears on root). <sup>Written for commit 1bdd7635ea432c564fe77fea57062df1a9d2f56d. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by:Will Chen <willchen90@gmail.com> Co-authored-by:
Claude Opus 4.5 <noreply@anthropic.com>