Skip to content

The design language that makes your AI harness better at design.

JavaScript

Kickers in a painted card, and columns a box clips

Paul Bakausb78174026ee5
diff --git a/crates/browser/tests/card_heuristics.rs b/crates/browser/tests/card_heuristics.rs
index 9dc39b2b6..5ed926bfd 100644
--- a/crates/browser/tests/card_heuristics.rs
+++ b/crates/browser/tests/card_heuristics.rs
@@ -239,6 +239,7 @@ fn page_level_misreads_stay_silent() {
("oversized-h1-rendered.html", "oversized-h1"),
("first-viewport-column-overflow-outline.html", "first-viewport-column-overflow"),
("first-viewport-column-overflow-tabs.html", "first-viewport-column-overflow"),
+ ("first-viewport-column-overflow-clipped.html", "first-viewport-column-overflow"),
("em-dash-pricing-matrix.html", "em-dash-overuse"),
] {
let Some(findings) = scan(fixture) else {
@@ -311,8 +312,9 @@ fn label_collectors_climb_and_scale() {
"A Single Kicker Still Flags",
"Relative Kicker Ceiling",
"Eyebrow In A Framer Wrapper",
+ "Label In A Tall Panel",
],
- &["Label Too Large For Its Heading", "Untracked Caps Label"],
+ &["Label Too Large For Its Heading", "Untracked Caps Label", "Press Card Source"],
);
let Some(findings) = scan("numbered-section-labels.html") else {
diff --git a/crates/core/src/browser/page_checks.rs b/crates/core/src/browser/page_checks.rs
index 8e16fef70..b63276d6e 100644
--- a/crates/core/src/browser/page_checks.rs
+++ b/crates/core/src/browser/page_checks.rs
@@ -2532,6 +2532,34 @@ pub fn check_text_occlusion_dom(dom: &dyn Dom) -> Vec<ElFinding> {
findings
}
+/// How far down `d` (laid out at `dr`) shows: its bottom, or the bottom of
+/// the nearest box between it and the row `row` (both ends included) that
+/// clips or scrolls on y, when that ends sooner. cuisineactuelle.fr's tile
+/// column runs eleven tiles into a 610px box that scrolls them, inside a
+/// section that hides the rest; the column a reader sees ends at 610px.
+fn column_visible_bottom(dom: &dyn Dom, d: ElId, dr: &Rect, row: ElId) -> f64 {
+ let mut bottom = dr.bottom;
+ let mut cur = dom.parent(d);
+ while let Some(p) = cur {
+ let y = {
+ let v = dom.style(p, "overflowY");
+ if v.is_empty() {
+ dom.style(p, "overflow").split_whitespace().last().unwrap_or("").to_string()
+ } else {
+ v
+ }
+ };
+ if matches!(y.as_str(), "hidden" | "clip" | "auto" | "scroll") && dom.style(p, "display") != "inline" {
+ bottom = math_min(bottom, dom.rect(p).bottom);
+ }
+ if p == row {
+ break;
+ }
+ cur = dom.parent(p);
+ }
+ bottom
+}
+
/// JS: checks.mjs#checkFirstViewportColumnOverflowDOM()
pub fn check_first_viewport_column_overflow_dom(dom: &dyn Dom) -> Vec<ElFinding> {
let mut findings = Vec::new();
@@ -2625,7 +2653,7 @@ pub fn check_first_viewport_column_overflow_dom(dom: &dyn Dom) -> Vec<ElFinding>
}
let dr = dom.rect(d);
if dr.width > 0.0 && dr.height > 0.0 {
- content_bottom = math_max(content_bottom, dr.bottom);
+ content_bottom = math_max(content_bottom, column_visible_bottom(dom, d, &dr, el));
}
}
// A column with nothing painted in its own flow (a collapsed
@@ -3327,6 +3355,16 @@ mod tests {
);
d.set_rect(b_in, 640.0, 0.0, 600.0, 900.0);
assert!(check_first_viewport_column_overflow_dom(&d).is_empty());
+
+ // observations-28 row 27: the tall column's box scrolls its content
+ // at 700px (cuisineactuelle.fr's tile list), so it ends where it is
+ // clipped, and the short column is short again.
+ d.set_rect(b_in, 640.0, 0.0, 600.0, 300.0);
+ d.set_styles(a, &[("overflowY", "auto")]);
+ d.set_rect(a, 0.0, 0.0, 640.0, 700.0);
+ assert!(check_first_viewport_column_overflow_dom(&d).is_empty(), "clipped at 700px");
+ d.set_styles(a, &[("overflowY", "visible")]);
+ assert_eq!(check_first_viewport_column_overflow_dom(&d).len(), 1, "unclipped");
}
/// cisco.com and picomq.com: a tab list, a collapsed panel and an outline
diff --git a/crates/core/src/browser/text_collectors.rs b/crates/core/src/browser/text_collectors.rs
index a0cca0dc4..6801441e8 100644
--- a/crates/core/src/browser/text_collectors.rs
+++ b/crates/core/src/browser/text_collectors.rs
@@ -50,6 +50,35 @@ pub fn is_kicker_card_context(dom: &dyn Dom, heading: ElId, kicker: ElId) -> boo
}
}
+/// Whether `kicker` sits in the card that holds `heading`: the nearest
+/// ancestor of the heading drawn as a card (a boundary of its own, read from
+/// the computed box), shorter than the viewport, whatever its tag. A label in
+/// a card beside its title is the card's metadata, as it is in an `article`
+/// or `li` card: aina-tech.io's white press card names its source ("The
+/// Future Media") over the headline in a `div`.
+fn kicker_in_painted_card(dom: &dyn Dom, heading: ElId, kicker: ElId) -> bool {
+ let viewport = {
+ let h = dom.inner_height();
+ if num_truthy(h) {
+ h
+ } else {
+ 800.0
+ }
+ };
+ let body = dom.body();
+ let mut cur = dom.parent(heading);
+ while let Some(c) = cur {
+ if Some(c) == body {
+ return false;
+ }
+ if super::page_checks::is_card_like_dom(dom, c) {
+ return dom.rect(c).height < viewport && dom.contains(c, kicker);
+ }
+ cur = dom.parent(c);
+ }
+ false
+}
+
static HEADING_LEVEL_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^h([1-6])$").expect("HEADING_LEVEL_RE"));
@@ -131,7 +160,7 @@ pub fn collect_kicker_candidates(dom: &dyn Dom) -> Vec<KickerCandidate> {
if super::dom::closest_or_none(dom, kicker, KICKER_SKIP_SELECTOR).is_some() {
continue;
}
- if is_kicker_card_context(dom, heading, kicker) {
+ if is_kicker_card_context(dom, heading, kicker) || kicker_in_painted_card(dom, heading, kicker) {
continue;
}
let heading_tag = tag_lower(dom, heading);
diff --git a/tests/fixtures/antipatterns/first-viewport-column-overflow-clipped.html b/tests/fixtures/antipatterns/first-viewport-column-overflow-clipped.html
new file mode 100644
index 000000000..50982f6a8
--- /dev/null
+++ b/tests/fixtures/antipatterns/first-viewport-column-overflow-clipped.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>first-viewport-column-overflow, a tile column its box scrolls</title>
+<!--
+ Should pass. An opening section sets a lead tile beside a column of eleven
+ smaller tiles. The column is a 610px box that scrolls its tiles, inside a
+ section that hides the rest (cuisineactuelle.fr). Laid out, the tiles run
+ to about three viewports; on screen both columns end at the 610px box, and
+ the fold falls where the section does. first-viewport-column-overflow.html
+ keeps the flag case.
+-->
+<style>
+ * { margin: 0; box-sizing: border-box; }
+ body { font-family: system-ui, sans-serif; color: #111111; background: #ffffff; }
+ p { margin: 0 0 14px; line-height: 1.6; }
+ .highlight { height: 610px; overflow: hidden; margin: 240px 40px 0; }
+ .tiles { display: flex; gap: 24px; height: 610px; }
+ .lead { flex: 1; height: 610px; overflow-y: auto; }
+ .lead article { height: 570px; background: #f3f3f3; padding: 16px; }
+ .column { flex: 1; height: 610px; overflow-y: auto; }
+ .column article { height: 152px; margin-bottom: 16px; background: #f3f3f3; padding: 16px; }
+</style>
+</head>
+<body>
+ <section class="highlight">
+ <div class="tiles">
+ <div class="lead"><article><p>The lead story, with its photo and standfirst.</p></article></div>
+ <div class="column">
+ <article><p>Second story.</p></article>
+ <article><p>Third story.</p></article>
+ <article><p>Fourth story.</p></article>
+ <article><p>Fifth story.</p></article>
+ <article><p>Sixth story.</p></article>
+ <article><p>Seventh story.</p></article>
+ <article><p>Eighth story.</p></article>
+ <article><p>Ninth story.</p></article>
+ <article><p>Tenth story.</p></article>
+ <article><p>Eleventh story.</p></article>
+ <article><p>Twelfth story.</p></article>
+ </div>
+ </div>
+ </section>
+</body>
+</html>
diff --git a/tests/fixtures/antipatterns/kicker-above-heading.html b/tests/fixtures/antipatterns/kicker-above-heading.html
index 89d3ec18f..f42cb4303 100644
--- a/tests/fixtures/antipatterns/kicker-above-heading.html
+++ b/tests/fixtures/antipatterns/kicker-above-heading.html
@@ -215,6 +215,10 @@
font-size: 24px;
line-height: 30px;
}
+ /* Round 7: a kicker inside a card drawn by its computed box, not its tag */
+ .press-panel { padding: 24px; background: #14161b; border-radius: 16px; }
+ .press-card { min-height: 180px; padding: 24px; background: #ffffff; border-radius: 16px; color: #14161b; }
+ .tall-panel { min-height: 900px; padding: 24px; background: #ffffff; border-radius: 16px; }
</style>
</head>
<body>
@@ -275,6 +279,14 @@
<div class="heading-wrap"><h2>"Eyebrow In A Framer Wrapper"</h2></div>
<p>The label's type lives on a p inside a bare div, and the heading leads its own wrapper.</p>
</section>
+
+ <section class="case">
+ <div class="tall-panel">
+ <span class="kicker">Platform overview</span>
+ <h2>"Label In A Tall Panel"</h2>
+ <p>A painted panel taller than the viewport is a section, not a card, and its eyebrow still flags.</p>
+ </div>
+ </section>
</section>
<section class="col" aria-label="Should pass">
@@ -402,6 +414,18 @@
</li>
</ol>
+ <section class="case">
+ <!-- Browser engine only: the card is read from its computed box. The
+ static engine, which has no layout, still reports it. -->
+ <div class="press-panel">
+ <div class="press-card">
+ <span class="kicker">The Future Media</span>
+ <h3>"Press Card Source"</h3>
+ <p>A white press card names its source over the headline; the label is the card's metadata, as it is in an article card.</p>
+ </div>
+ </div>
+ </section>
+
<div class="hidden-mockup" aria-hidden="true">
<div class="mockup-hero">
<span class="taxonomy-label">Amalfi Coast</span>