max / makeover-webview
- Co-Authored-By
- Claude Opus 5 (1M context) <noreply@anthropic.com>
1 file changed,
+29 insertions,
-0 deletions
| @@ -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()); |