Skip to content

fix(docsite): prevent stale template previews on opening and reopening - #6167

Open
Angadslr wants to merge 4 commits into
facebook:mainfrom
Angadslr:fix/template-preview-flicker
Open

fix(docsite): prevent stale template previews on opening and reopening#6167
Angadslr wants to merge 4 commits into
facebook:mainfrom
Angadslr:fix/template-preview-flicker

Conversation

@Angadslr

@Angadslr Angadslr commented Sep 8, 2026

Copy link
Copy Markdown

Opening a template could briefly render the previous template’s preview while the header already showed the selected template.

Render direct selections immediately, reserving deferred previews for pending previous/next navigation. Retire that preview-pending state when the dialog closes or the selection changes, so unfinished navigation cannot keep a newly selected template covered by its loading skeleton.

Regression coverage

  • Opening a non-first template, including fullscreen.
  • Closing and reopening another template.
  • Direct index changes and initial deep-linked selection.
  • Previous/next navigation and its pending skeleton.
  • Closing during suspended navigation, then opening a third template before completion.

The new pending-navigation regression fails before the latest correction and passes afterward.

Validation

  • All 10 focused tests pass.
  • Docsite typecheck passes.
  • Changed-file lint passes.

Bug recording

https://youtu.be/DUU9HG8Bk54

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Error Error Sep 10, 2026 8:21pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 8, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Sep 8, 2026
github-actions Bot added a commit that referenced this pull request Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime fix correctly prevents the selected template from opening with stale preview content, but this PR also adds an unrelated regression for the earlier dialog-teardown fix.

In template-preview-dialog.test.ts, please remove releases the dialog on playground route hiding and unmount and the Activity / HTMLDialogElement.close harness used only by that case. The call-count assertion locks a private teardown mechanism that this change does not modify, so future dialog lifecycle work could fail a stale-preview suite for an unrelated reason. Keep the opening, direct-selection, and pending-navigation cases that prove this fix and preserve its interaction boundary.

[Reviewed by Robohands]

@github-actions
github-actions Bot requested a review from cixzhang September 9, 2026 18:58
@Angadslr

Angadslr commented Sep 9, 2026

Copy link
Copy Markdown
Author

Fixed and pushed. The dialog now renders the selected template immediately while preserving deferred previous/next navigation. Regression tests cover opening, reopening, URL changes, navigation, fullscreen behavior, and Playground teardown.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the ordinary stale-open path and removing the unrelated teardown coverage. One stale-preview path remains: if someone closes while previous/next navigation is pending and immediately opens another template, isPending still belongs to the superseded navigation, so the new dialog can render the old deferred preview until that navigation settles. Please make current selection win over superseded work and add a regression for pending navigation → close → open a third card before completion. If you would rather talk it through with someone, we are in Discord.

@cixzhang
cixzhang dismissed their stale review September 10, 2026 04:34

Superseded by #6167 (review) on exact head 5c3b1d7.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the ordinary stale-open path and removing the unrelated teardown coverage. One stale-preview path remains: if someone closes while previous/next navigation is pending and immediately opens another template, isPending still belongs to the superseded navigation, so the new dialog can render the old deferred preview until that navigation settles. Please make current selection win over superseded work and add a regression for pending navigation → close → open a third card before completion. If you would rather talk it through with someone, we are in Discord.

@Angadslr Angadslr changed the title fix(docsite): prevent stale template preview on dialog opening fix(docsite): prevent stale template previews on opening and reopening Sep 10, 2026

@kentonquatman kentonquatman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks great from the design side! Thanks for providing the video showing the bug, it was very helpful!

github-actions Bot added a commit that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants