From 430603ec001b749811502af8eb032a4036eecc25 Mon Sep 17 00:00:00 2001 From: slhx agent Date: Mon, 22 Jun 2026 22:12:27 +0200 Subject: [PATCH] feat(examples): make v0 todo rename form editable Turn the v0 todo row rename action into an editable generated form instead of a fixed submit value, and preserve validation/recovery behavior for blank titles. This keeps the beginner exemplar on generated form handles and user-visible recovery instead of hidden demo shortcuts. req: examples/001 req: canonical_authoring/003 --- examples/v0/src/main.rs | 21 ++++++++++++++++++++ examples/v0/templates/partials/todo_row.heml | 8 ++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/v0/src/main.rs b/examples/v0/src/main.rs index 4f5558c..5b0301b 100644 --- a/examples/v0/src/main.rs +++ b/examples/v0/src/main.rs @@ -402,6 +402,13 @@ mod auth_handlers { fn rename_todo_effect(state: Arc, form: RenameTodo) -> impl IntoEffect { // req: examples/001 req: canonical_authoring/003 + if form.title.as_str().is_empty() { + return Some(( + todo_row::rename_todo_form.focus("title"), + todos::notice.set("Add a title before renaming"), + )); + } + let mut todos = state.todos.lock().unwrap(); todos .iter_mut() @@ -710,6 +717,20 @@ mod tests { assert!(add.payload_contains("Added Ship v0")); assert!(add.resets_form(todos::new_todo)); + let rename_validation = inspect_batch( + InteractionRequest::from(form( + todo_row::rename_todo, + &[("id", "1"), ("title", " ")], + )) + .dispatch_async(handlers(state.clone())) + .await + .unwrap() + .batch, + ); + assert_eq!(state.todos.lock().unwrap()[0].title, "Ship v0"); + assert!(rename_validation.payload_contains("Add a title before renaming")); + assert!(rename_validation.updates_text(todos::notice)); + let rename = inspect_batch( InteractionRequest::from(form( todo_row::rename_todo, diff --git a/examples/v0/templates/partials/todo_row.heml b/examples/v0/templates/partials/todo_row.heml index fe3cf18..1d73acb 100644 --- a/examples/v0/templates/partials/todo_row.heml +++ b/examples/v0/templates/partials/todo_row.heml @@ -1,8 +1,12 @@
  • {+ self.title +} -
    + - + +