Skip to content

Commit e1dec33

Browse files
author
Foscat
committed
fix: harden responsive review regressions
1 parent fde826c commit e1dec33

2 files changed

Lines changed: 88 additions & 3 deletions

File tree

demo/demo.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ body[data-ecosystem="all-three"] .demo-status {
497497
inset-block-start: 6rem;
498498
display: block;
499499
max-block-size: calc(100vh - 7rem);
500-
max-block-size: calc(100dvh - 7rem);
501500
max-block-size: calc(100svh - 7rem);
501+
max-block-size: calc(100dvh - 7rem);
502502
overflow: auto;
503503
}
504504
}
@@ -519,8 +519,8 @@ body[data-ecosystem="all-three"] .demo-status {
519519
z-index: 40;
520520
inline-size: min(24rem, calc(100% - 1rem));
521521
max-block-size: 100vh;
522-
max-block-size: 100dvh;
523522
max-block-size: 100svh;
523+
max-block-size: 100dvh;
524524
padding:
525525
max(1rem, env(safe-area-inset-top, 0px))
526526
max(1rem, env(safe-area-inset-right, 0px))

test/demo-smoke.test.mjs

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,29 @@ const assertStaticDemoContract = () => {
179179
assert.match(demoCss, /--demo-container-block-size/);
180180
assert.match(demoCss, /data-demo-height-tier="short"/);
181181
assert.match(demoCss, /data-demo-height-tier="shallow"/);
182-
assert.match(demoCss, /100dvh/);
182+
assert.equal(
183+
(
184+
demoCss.match(
185+
/min-block-size:\s*100vh;\s*min-block-size:\s*100svh;\s*min-block-size:\s*100dvh;/g
186+
) ?? []
187+
).length,
188+
1,
189+
"The page minimum height must prefer dvh after its vh and svh fallbacks."
190+
);
191+
assert.equal(
192+
(
193+
demoCss.match(
194+
/max-block-size:\s*100vh;\s*max-block-size:\s*100svh;\s*max-block-size:\s*100dvh;/g
195+
) ?? []
196+
).length,
197+
1,
198+
"The mobile controls drawer must prefer dvh after its vh and svh fallbacks."
199+
);
200+
assert.match(
201+
demoCss,
202+
/max-block-size:\s*calc\(100vh - 7rem\);\s*max-block-size:\s*calc\(100svh - 7rem\);\s*max-block-size:\s*calc\(100dvh - 7rem\);/,
203+
"The desktop controls must prefer dvh after their vh and svh fallbacks."
204+
);
183205
};
184206

185207
const contentTypes = {
@@ -507,6 +529,21 @@ const verifyHeightBehavior = async (page, baseUrl) => {
507529
);
508530
await page.waitForFunction(() => document.body.dataset.demoReady === "true");
509531

532+
const standaloneStickyPosition = await page.evaluate(() => {
533+
const fixture = document.createElement("header");
534+
fixture.className = "ly-header--sticky";
535+
fixture.style.setProperty("--ly-sticky-position", "initial");
536+
document.body.append(fixture);
537+
const position = getComputedStyle(fixture).position;
538+
fixture.remove();
539+
return position;
540+
});
541+
assert.equal(
542+
standaloneStickyPosition,
543+
"sticky",
544+
"A sticky header outside a token scope must retain its safe default."
545+
);
546+
510547
const samples = [
511548
{ height: 464, shell: "auto", position: "static", tier: "shallow" },
512549
{ height: 496, shell: "100dvh", position: "sticky", tier: "short" },
@@ -567,6 +604,49 @@ const verifyHeightBehavior = async (page, baseUrl) => {
567604
}
568605
};
569606

607+
const verifyDefaultFontHeightTiers = async (baseUrl) => {
608+
if (browserName !== "chromium") return;
609+
610+
/*
611+
Chromium can apply a real browser-default font preference at launch.
612+
This validates rem conversion without overriding the page's authored root size.
613+
*/
614+
const fontBrowser = await chromium.launch({
615+
headless: true,
616+
args: ["--blink-settings=defaultFontSize=20"]
617+
});
618+
const fontPage = await fontBrowser.newPage();
619+
620+
try {
621+
await installExternalFixtures(fontPage);
622+
623+
for (const sample of [
624+
{ height: 550, tier: "shallow" },
625+
{ height: 800, tier: "short" },
626+
{ height: 920, tier: "regular" }
627+
]) {
628+
await fontPage.setViewportSize({ width: 1440, height: sample.height });
629+
await fontPage.goto(
630+
`${baseUrl}?ecosystem=layout-only&wrapper=full&recipe=app-shell&container=73rem`,
631+
{ waitUntil: "domcontentloaded" }
632+
);
633+
await fontPage.waitForFunction(() => document.body.dataset.demoReady === "true");
634+
635+
const result = await fontPage.evaluate(() => ({
636+
fontSize: getComputedStyle(document.documentElement).fontSize,
637+
tier: document.querySelector(".demo-preview-root").dataset.demoHeightTier
638+
}));
639+
assert.deepEqual(
640+
result,
641+
{ fontSize: "20px", tier: sample.tier },
642+
`The ${sample.height}px viewport ignored the 20px browser default font size.`
643+
);
644+
}
645+
} finally {
646+
await fontBrowser.close();
647+
}
648+
};
649+
570650
const verifyDeviceMatrix = async (page, baseUrl) => {
571651
await page.goto(`${baseUrl}?ecosystem=layout-only&wrapper=full`, {
572652
waitUntil: "domcontentloaded"
@@ -801,6 +881,10 @@ const verifyPrimitiveOverflow = async (page, baseUrl) => {
801881

802882
if (primitive === "scroll") {
803883
assert(result.vertical > 2 && result.overflowY === "auto", "Scroll must be vertically bounded.");
884+
assert(
885+
!["auto", "scroll", "visible"].includes(result.overflowX),
886+
`The bounded vertical scroll primitive exposed inline overflow as ${result.overflowX}.`
887+
);
804888
} else {
805889
assert(
806890
!(result.vertical > 2 && ["auto", "scroll"].includes(result.overflowY)),
@@ -862,6 +946,7 @@ try {
862946
await verifyTopologyEdges(page, server.baseUrl);
863947
await verifyManualAndNearestContainer(page, server.baseUrl);
864948
await verifyHeightBehavior(page, server.baseUrl);
949+
await verifyDefaultFontHeightTiers(server.baseUrl);
865950
await verifyDeviceMatrix(page, server.baseUrl);
866951
await verifyPersonalityMatrix(page, server.baseUrl);
867952
await verifyMinimumWidth(page, server.baseUrl);

0 commit comments

Comments
 (0)