Skip to content

Commit 33b14e4

Browse files
Programcodeclaude
andcommitted
Swallow the skipped view transition when a theme switch interrupts another
Codex review r2 on #124: switching theme twice before the first transition was ready left its ready promise rejected and unhandled (AbortError: Transition was skipped). The final theme was already correct. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9bccae8 commit 33b14e4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/components/ThemeProvider.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function applyTheme(resolved: ResolvedTheme, animate: boolean) {
3030

3131
// One 200ms crossfade of the whole page instead of every surface easing at its own speed.
3232
if (typeof document.startViewTransition === 'function') {
33-
document.startViewTransition(swap);
33+
const transition = document.startViewTransition(swap);
34+
// A newer switch skips this one's animation; the class swap still runs, so that's fine.
35+
transition.ready.catch(() => {});
36+
transition.finished.catch(() => {});
3437
return;
3538
}
3639

0 commit comments

Comments
 (0)