Skip to main content

max / makeover-webview

Emit the input type for email, url and tel The three kinds makeover-layout gained, each mapping to the HTML type that carries a touch keyboard and the platform's validation with it. A test asserts the type directly, since emitting text for any of them is the exact regression the variants exist to prevent. input_type also takes a wildcard now that FieldKind is non_exhaustive. Text degrades rather than dropping the field, which is right here: text accepts any value the typed kinds would, so an unknown kind renders usable and plain instead of not rendering. Cargo.toml is deliberately not in this commit. It carries a temporary patch.crates-io pointing makeover-layout at the working tree, since the description is still gaining members as the goingson wiring finds them. That patch comes out before publish.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-30 12:54 UTC
Signed with PGP, not checked
Commit: 891c3e5249be752a9f24a1286bca67565c7dd85e
Parent: ea190c1
1 file changed, +29 insertions, -0 deletions
M src/form.rs +29
@@ -175,8 +175,19 @@
175 175 FieldKind::Number => "number",
176 176 FieldKind::Checkbox => "checkbox",
177 177 FieldKind::Hidden => "hidden",
178 + // Not decoration. Each of these changes the keyboard a touch device
179 + // offers and turns on the platform's own validation, which is why the
180 + // description names them apart from text rather than letting the app
181 + // pass an HTML type through.
182 + FieldKind::Email => "email",
183 + FieldKind::Url => "url",
184 + FieldKind::Tel => "tel",
178 185 // Select and Textarea are not inputs at all; they never reach here.
179 186 FieldKind::Text | FieldKind::Select | FieldKind::Textarea => "text",
187 + // A kind added to the description since this renderer was built. Text
188 + // accepts any value the others would, so it degrades rather than
189 + // dropping the field.
190 + _ => "text",
180 191 }
181 192 }
182 193
@@ -598,6 +609,24 @@
598 609 assert_eq!(html, r#"<input type="hidden" name="title" value="42">"#);
599 610 }
600 611
612 + /// These three exist so a touch keyboard and the platform's validation
613 + /// arrive with the field. Emitting text for any of them is the regression
614 + /// the variants were added to prevent, so the type is asserted directly.
615 + #[test]
616 + fn the_typed_text_kinds_keep_their_input_type() {
617 + for (kind, expected) in [
618 + (FieldKind::Email, "email"),
619 + (FieldKind::Url, "url"),
620 + (FieldKind::Tel, "tel"),
621 + ] {
622 + let html = field_html(&field(kind), &Filling::default(), &Emit::default());
623 + assert!(
624 + html.contains(&format!(r#"type="{expected}""#)),
625 + "{kind:?} emitted {html}"
626 + );
627 + }
628 + }
629 +
601 630 #[test]
602 631 fn no_prefix_leaves_the_id_as_the_name() {
603 632 let html = field_html(&field(FieldKind::Text), &Filling::default(), &Emit::default());