fix: enforce handbook scrollbar and reduced motion contracts

This commit is contained in:
maoyingjie
2026-10-27 21:10:51 +08:00
parent b1344d8a4c
commit 202e3a5b5d
23 changed files with 702 additions and 23 deletions
+37
View File
@@ -326,6 +326,43 @@ it("keeps non-modal content interactive outside without claiming a modal lock",
});
describe("floating overlay animation lifecycle", () => {
it("clears an entrance cancelled by an ancestor reduced-motion change", async () => {
const { useOverlayAnimation } =
await import("../packages/vue/src/components/overlay/animation");
const element = ref<HTMLElement>();
const reduced = ref(false);
let phase!: ReturnType<typeof useOverlayAnimation>;
const realStyle = getComputedStyle;
const css = vi
.spyOn(window, "getComputedStyle")
.mockImplementation((el) => {
if (el === element.value)
return {
animationName: el.closest('[data-reduce-motion="true"]')
? "none"
: "enter",
} as CSSStyleDeclaration;
return realStyle(el);
});
try {
fixture(
'<section :data-reduce-motion="reduced ? \'true\' : undefined"><div ref="element" /></section>',
() => {
phase = useOverlayAnimation(ref(true), element);
return { element, reduced };
},
);
await settle();
expect(phase.entering.value).toBe(true);
reduced.value = true;
await settle();
// No synthetic animationend: CSS cancels the entrance entirely.
expect(phase.entering.value).toBe(false);
} finally {
css.mockRestore();
}
});
async function animationFixture(transform: string, animated = true) {
const { useOverlayAnimation } =
await import("../packages/vue/src/components/overlay/animation");