Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions e2e/video-fit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,40 @@ test("旋转 90° 后画面按新方向铺满播放器(#1844)", async ({ pag
)
.toBe("fitted");
});

test("旋转 ⇄ 转回横向时按钮降档随实宽重估(#1844 复测)", async ({ page }) => {
await openPlayer(page);

const classes = () =>
page.evaluate(() => {
const player = document.querySelector(".art-video-player")!;
return {
compact: player.classList.contains("vp-compact"),
ultra: player.classList.contains("vp-ultra"),
width: Math.round(player.getBoundingClientRect().width),
};
});

// 宽容器(e2e 视口)下两档均不应置位
const base = await classes();
expect(base.compact).toBe(false);
expect(base.ultra).toBe(false);

// 旋转 90°:$player 收窄成纵向框(<560 → vp-ultra)
await rotateFrame(page);
await expect
.poll(async () => (await classes()).ultra, { timeout: 3000 })
.toBe(true);

// 转回横向:实宽恢复,两档必须随之清除——滞留即 #1844 复发的 bug
await rotateFrame(page);
await expect
.poll(
async () => {
const c = await classes();
return !c.compact && !c.ultra ? "restored" : "stale";
},
{ timeout: 3000 },
)
.toBe("restored");
});
6 changes: 6 additions & 0 deletions src/components/Content/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,12 @@ export default function VideoPlayer({
video.style.top = "";
if (!art.fullscreenWeb) art.autoSize();
}
// 旋转过渡改变了 $player 实宽(旋转态收窄成纵向框 / 转回 autoSize 恢复宽框),
// 但容器尺寸不变 → ResizeObserver 不触发,autoSize 只 emit "autoSize" 不 emit
// "resize" → applyCompact 不会被任何路径重跑,档位跨旋转滞留(#1844 复测:
// 旋转态窗口 resize 置位缩小档后转回横向,按钮不恢复全尺寸)。样式写入为同步,
// 此处量到的已是过渡后的布局。
applyCompact();
};
refitForRotationRef.current = refitForRotation;
applyCompact();
Expand Down
Loading