From 6427afd12b2a23f0efe0a50e0f8bcc6ef3718209 Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Tue, 6 Oct 2026 10:08:17 +0000 Subject: [PATCH] Reset the game options form when the game changes The creation options were rendered as a keyed list, so a field shared by two games (target_score) kept the previous game's widget when the game changed: after switching scopone -> briscola the input still showed 11 with scopone's min/max instead of the briscola default 61 (1/100 instead of 61/120), even though the submitted payload was already correct. Recreate the option inputs on every game switch instead, so each one is initialized from the new game's defaults and schema constraints. --- web/src/pages/lobby.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/src/pages/lobby.rs b/web/src/pages/lobby.rs index 73bf33f..a4eb333 100644 --- a/web/src/pages/lobby.rs +++ b/web/src/pages/lobby.rs @@ -671,13 +671,21 @@ pub fn LobbyPage() -> View { div(class="mb-3") { (players_note) } } })) - Keyed( - list=fields, - view=move |f| view! { - OptionInput(field=f.clone(), options=options) - }, - key=|f| f.key.clone(), - ) + // Recreate the option inputs on every + // game switch: keyed rendering kept + // the previous game's field (value, + // min/max) for shared keys such as + // target_score. + (move || { + let _game = selected_game.get_clone(); + fields + .get_clone() + .into_iter() + .map(|f| view! { + OptionInput(field=f, options=options) + }) + .collect::>() + }) button( class="btn btn-warning btn-lg w-100 mt-auto", on:click=on_create,