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.
This commit is contained in:
+15
-7
@@ -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::<Vec<_>>()
|
||||
})
|
||||
button(
|
||||
class="btn btn-warning btn-lg w-100 mt-auto",
|
||||
on:click=on_create,
|
||||
|
||||
Reference in New Issue
Block a user