check-preview-modal-scroll-lock.mjs
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const scriptDir = dirname(fileURLToPath(import.meta.url));
const pagePath = join(scriptDir, "..", "src", "app", "page.tsx");
const source = readFileSync(pagePath, "utf8");
const requiredSnippets = [
{
name: "modal open locks document body scrolling",
snippet: 'document.body.style.overflow = "hidden";',
},
{
name: "modal cleanup restores document body scrolling",
snippet: "document.body.style.overflow = previousBodyOverflow;",
},
{
name: "preview overlay isolates scroll chaining",
snippet: "overscroll-contain",
},
{
name: "preview overlay keeps wheel events inside the modal layer",
snippet: "onWheel={(e) => e.stopPropagation()}",
},
];
const missing = requiredSnippets.filter(({ snippet }) => !source.includes(snippet));
if (missing.length > 0) {
console.error("Preview modal scroll lock regression check failed:");
for (const item of missing) {
console.error(`- Missing: ${item.name}`);
}
process.exit(1);
}
console.log("Preview modal scroll lock regression check passed.");