The password box was a browser default under a styled username box

board.css styled form controls from a list — text, email, date, and inputs with
no type attribute at all. The username field on the sign-in page has no type, so
it got the full-width box; the password field has one, and `password` was never
in the list, so it kept the browser's own narrow grey rectangle directly beneath
it. The number box for a page's order, added two days ago, was unstyled for the
same reason and nobody had looked at it yet.

An allowlist of accepted types is wrong the moment somebody adds a field, and
wrong silently: nothing errors, the form just looks unfinished. So the rule is
written the other way round — it excludes the controls that are not text boxes
(checkbox, radio, file, and the button-like types) and styles everything else,
so password, number, url, search and whatever arrives next are covered without
anybody remembering to edit it.

The guard in test_templates.py is on the shape of the rule rather than on any
one type: a revert to listing accepted types fails it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
This commit is contained in:
Claude 2026-10-03 09:12:07 +00:00
parent 4e82f66d08
commit 8608e71c7e
No known key found for this signature in database
2 changed files with 50 additions and 3 deletions

View File

@ -180,8 +180,22 @@ label { display: block; margin: 1rem 0 0.35rem; font-weight: 600; font-size: 0.9
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; } label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
label.check input { margin: 0; } label.check input { margin: 0; }
input[type="text"], input[type="email"], input[type="date"], /* Everything a person types in, named by what it is NOT.
input:not([type]), select, textarea { *
* This was a list — text, email, date and inputs with no type at all — and a
* list of accepted types is wrong the moment somebody adds one. It was: the
* password box on the sign-in page was a browser default sitting under a
* full-width username box, because `password` was never added, and so was the
* number box for a page's order. Nothing errors; the form just looks unfinished
* in a way only a person looking at it can catch.
*
* The controls below are excluded because they are not text boxes and would be
* disfigured by this: a checkbox, a radio, a file picker (styled separately),
* and the button-like types. Anything else — password, number, url, search,
* tel, whatever arrives next — is a field somebody types in and gets the same
* box without this rule having to be edited again. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
select, textarea {
width: 100%; width: 100%;
padding: 0.6rem 0.75rem; padding: 0.6rem 0.75rem;
border: 1px solid var(--border-light); border: 1px solid var(--border-light);
@ -189,7 +203,7 @@ input:not([type]), select, textarea {
background: var(--bg); background: var(--bg);
color: var(--text); color: var(--text);
} }
input[type="checkbox"] { width: auto; } input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { resize: vertical; line-height: 1.55; } textarea { resize: vertical; line-height: 1.55; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; } :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

View File

@ -174,3 +174,36 @@ def test_the_fields_that_are_not_prose_stay_plain():
html = (Path(__file__).resolve().parents[1] / "templates" / name).read_text(encoding="utf-8") html = (Path(__file__).resolve().parents[1] / "templates" / name).read_text(encoding="utf-8")
opening = re.search(rf'<textarea id="{box}"[^>]*>', html) opening = re.search(rf'<textarea id="{box}"[^>]*>', html)
assert opening and "data-markdown" not in opening.group(0), name assert opening and "data-markdown" not in opening.group(0), name
# --- the form controls are named by what they are not ---------------------
UNSTYLED_ON_PURPOSE = {"checkbox", "radio", "file", "submit",
"button", "reset", "image", "hidden"}
def test_the_form_rule_is_an_exclusion_and_not_a_list_of_accepted_types():
"""It used to be `input[type=text], input[type=email], input[type=date],
input:not([type])` — an allowlist, which is wrong the moment anybody adds a
field. It was: the password box on the sign-in page was a browser default
sitting under a full-width username box, and the number box for a page's
order was the same. Nothing errors; the form just looks unfinished, which
only a person looking at it can catch.
So the guard is on the shape of the rule rather than on any one type: it has
to exclude the controls that are not text boxes and style everything else.
"""
css = (Path(__file__).resolve().parents[1] / "static" / "board.css").read_text(encoding="utf-8")
selector = [line for line in css.splitlines() if line.startswith("input:not(")]
assert selector, (
"board.css has no `input:not(...)` form rule. If it is back to listing "
"accepted types, the next field somebody adds will be unstyled."
)
excluded = set(re.findall(r'\[type="([a-z]+)"\]', selector[0]))
assert excluded == UNSTYLED_ON_PURPOSE, (
f"the stylesheet excludes {sorted(excluded)}; expected "
f"{sorted(UNSTYLED_ON_PURPOSE)}. Anything a person types in belongs in "
"the rule, not outside it."
)
for typed_in in ("password", "number", "email", "date", "text", "search", "url"):
assert typed_in not in excluded, f"{typed_in} is a box somebody types in"