Skip to content

fix(theme): keep all surfaces in sync when switching appearance - #3628

Merged
SoonIter merged 6 commits into
web-infra-dev:mainfrom
fi3ework:fix-theme-switch-transition
Aug 26, 2026
Merged

SoonIter merged 6 commits into
web-infra-dev:mainfrom
fi3ework:fix-theme-switch-transition

Conversation

@fi3ework

@fi3ework fi3ework commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Summary

before:

before.mp4

after:

iShot_2026-08-26_12.43.16.mp4

When switching the theme, the nav faded its background over 0.2s (and shiki code blocks over 0.5s) while the rest of the page switched instantly, producing a visible mismatch. The nav transition was introduced in #3017 for the home-page scroll transparent/opaque effect, not for theme switching.

This PR suppresses CSS transitions for one frame while the theme class flips (in applyThemeToDOM, the single entry point for all theme changes), so every themed surface switches in sync. The suppression is deliberately a temporary global transition: none rather than a nav-specific override: it cannot be re-overridden by the nav's own transition rule, and it also covers any other component that declares a transition on themed properties, now or in the future. The scroll-driven nav fade on the home page is unaffected. The nav transition now also animates border-bottom-color instead of the layout-affecting border-bottom shorthand.

Related Issue

N/A

Screenshots

Uploading before/after comparison videos...

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Suppress CSS transitions for one frame while the theme class flips, so
the nav (0.2s) and shiki code blocks (0.5s) no longer fade at their own
pace while the rest of the page switches instantly. The nav transition
itself is kept for the home-page scroll transparent/opaque effect, and
now animates border-bottom-color instead of the layout-affecting
border-bottom shorthand.
Copilot AI lite review requested due to automatic review settings August 26, 2026 03:51

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2da6b91ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/theme/logic/useThemeState.ts Outdated

Copilot AI 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.

Pull request overview

This PR improves appearance switching in the default theme by ensuring all themed UI surfaces update simultaneously, eliminating mismatched fade transitions during a theme toggle (while keeping the scroll-driven nav fade behavior intact).

Changes:

  • Temporarily suppresses CSS transitions for one animation frame during the theme class flip in the single theme-application entry point (applyThemeToDOM).
  • Adjusts the nav transition to animate border-bottom-color (instead of the border-bottom shorthand) to avoid layout-affecting transition semantics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/theme/logic/useThemeState.ts Injects/removes a temporary global transition: none rule around the theme DOM update to synchronize surface switching.
packages/core/src/theme/components/Nav/index.scss Updates nav transition to animate border-bottom-color instead of border-bottom.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/core/src/theme/logic/useThemeState.ts Outdated
Comment thread packages/core/src/theme/logic/useThemeState.ts Outdated
- Replace the injected <style> with a static base.css rule toggled via a
  root class, so the suppression works under strict CSP and also covers
  ::before/::after pseudo-elements
- Apply the same CSP-safe pattern to removeClipViewTransition
- Skip the suppression (and its forced style recalcs) when the DOM
  already matches the theme, e.g. on the post-hydration call
- Add unit tests for applyThemeToDOM

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 532a5aae66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/theme/styles/base.css Outdated
- Extract applyThemeToDOM into its own React-free module so the test
  needs no runtime mock or testing-only export
- Move the scrollbar suppression next to the transition it cancels in
  scrollbar.scss, scoped to .rp-scrollbar instead of the universal bucket
- Move the appearance view-transition rule into SwitchAppearance's
  global.scss where its sibling rules live
- Fold the suppression toggle into a single guarded block and mark the
  forced style flush with void so it does not read as dead code
@fi3ework
fi3ework requested a review from SoonIter August 26, 2026 07:44

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread packages/core/src/theme/logic/applyThemeToDOM.ts
@SoonIter
SoonIter enabled auto-merge (squash) August 26, 2026 09:25
@SoonIter
SoonIter merged commit 1345b2d into web-infra-dev:main Aug 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants