Skip to content

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

JavaScript

A custom checkbox row's label is not fine print

Paul Bakaus7078bcf2cb45
diff --git a/crates/core/src/checks/text_context.rs b/crates/core/src/checks/text_context.rs
index 7f9227eed..5690cca7e 100644
--- a/crates/core/src/checks/text_context.rs
+++ b/crates/core/src/checks/text_context.rs
@@ -574,10 +574,11 @@ pub fn is_fine_print<N: ContextNode>(el: &N) -> bool {
}
cur = c.parent();
}
- if el
- .children()
- .iter()
- .any(|k| matches!(k.tag().as_str(), "input" | "select" | "textarea" | "button"))
+ // A form control beside the text, or inside it, makes it the control's
+ // label: a custom checkbox row keeps the input next to a span.
+ let control = |k: &N| matches!(k.tag().as_str(), "input" | "select" | "textarea" | "button");
+ if el.children().iter().any(control)
+ || el.parent().is_some_and(|p| p.children().iter().any(control))
{
return false;
}
diff --git a/crates/html/tests/advisory_contexts.rs b/crates/html/tests/advisory_contexts.rs
index 7384718f6..ca9449284 100644
--- a/crates/html/tests/advisory_contexts.rs
+++ b/crates/html/tests/advisory_contexts.rs
@@ -112,6 +112,19 @@ fn fine_print_is_advisory_and_a_consent_label_fails() {
&& f.snippet.contains("1.20x")));
}
+#[test]
+fn a_custom_checkbox_rows_label_is_not_fine_print() {
+ // The input sits beside the span that labels it, not around it.
+ let f = scan(
+ "<div class=\"legal\"><input type=\"checkbox\"><span style=\"font-size: 10px\">I agree that my data is processed under the terms above.</span></div>\
+ <div class=\"legal\"><span style=\"font-size: 10px\">Prices include VAT where it applies to the order.</span></div>",
+ );
+ // The checkbox row's label keeps failing; the VAT note is fine print.
+ let mut got: Vec<&str> = f.iter().filter(|x| x.antipattern == "tiny-text").map(|x| x.severity.as_str()).collect();
+ got.sort();
+ assert_eq!(got, vec!["advisory", "warning"], "{f:#?}");
+}
+
#[test]
fn text_in_a_framed_demo_is_advisory_under_three_rules() {
let f = scan_fixture("mockup-structure.html");