Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): handle skipped view transition promises #8802

Openunjica(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8802/headopened

Showing 3 changed files with 87 additions and 2 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/cold-ravens-raise.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-core': patch
+---
+​
+Handle rejected ready and finished promises when a view transition is skipped.
7 additions and 2 deletionspackages/router-core/src/router.tsModified
View file
@@ -2476,8 +2476,13 @@
startViewTransitionParams = fn
- return (document as any).startViewTransition(startViewTransitionParams)
- .updateCallbackDone
+ const transition = (document as any).startViewTransition(
+ startViewTransitionParams,
+ )
+ // Skipped transitions reject these promises without failing the update.
+ transition.ready?.catch(() => {})
+ transition.finished?.catch(() => {})
+ return transition.updateCallbackDone
return fn()
75 additions and 0 deletionspackages/router-core/tests/view-transition.test.tsAdded
View file
@@ -0,0 +1,75 @@
+import { afterEach, expect, test, vi } from 'vitest'
+import { createMemoryHistory } from '@tanstack/history'