fix(motion): 站内跳转白屏——路由内容不再走 AnimatePresence wait 退场
现象:生产环境所有站内跳转白屏,地址与标题已切换,刷新才恢复。
根因:AnimatePresence mode="wait" 要求新页等旧页退场完成才挂载;App Router
导航期间的重复渲染会重置退场完成标记,切换 state 的窗口被错过,
motion.div 永久停在 exit 变体(opacity:0; translateY(-8px))。
修法:路由内容只保留 key={pathname} 的 280ms 入场;首屏仍由 mounted 渲染
裸 children;reduce 变体改为显式可见终值,避免切到空变体时冻结在半透明。
守卫:新增 client-navigation-visibility(导航后落定再读祖先链乘积);
首屏用例改逐帧采样;视觉用例改逐屏滚动触发 whileInView。
验证:E2E 20/20(四浏览器)、视觉 125/125、单测 1815、type-check/lint 0 error。
This commit is contained in:
1 parent
092ed385b0
commit
2f86c4419a
7 files changed
+167
-54
No files matched your search
@@ -64,11 +64,13 @@ for (const { path, lateHeading } of CASES) {
|
||||
});
|
||||
expect(h1Opacity, '首屏 h1 的祖先链不得停在半透明/0').toBeGreaterThan(0.99);
|
||||
|
||||
// 滚到底部,让 whileInView 触发;reduce 下应「一步到位」变可见
|
||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
||||
await page.waitForTimeout(1000);
|
||||
// 把目标滚进视口,让 whileInView 触发;reduce 下应「一步到位」变可见。
|
||||
// 不能 `window.scrollTo(0, scrollHeight)` 直接跳底:reduce 会禁用平滑滚动(瞬时跳转),
|
||||
// 目标从视口外被越过、IntersectionObserver 永不回调 ⇒ 探针自设条件造成假红。
|
||||
const late = page.getByRole('heading', { name: lateHeading }).first();
|
||||
await expect(late, '末段标题应存在(页面完整)').toBeVisible({ timeout: 10000 });
|
||||
await late.scrollIntoViewIfNeeded();
|
||||
await page.waitForTimeout(1000);
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
|
||||
Reference in new issue
Block a user