fix: enforce handbook scrollbar and reduced motion contracts
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user