fix Preserve selected feedback scores

Defer automatic feedback submission by one event-loop tick. The browser now applies the clicked radio value before the form data is collected, so completed feedback reports retain their selected signals instead of appearing empty. Repeated clicks on the selected score still advance.

Commit
ad7ddee0445f111b3e904c72d241f58b65c4a2b6
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
lib/web/workout_client.ml
index 5c0463c9..12aca865 100644..100644
@@ -412,7 +412,8 @@
412 412
413 413 (* Selecting a score advances to the next factor without a separate Next
414 414 action. Handle click rather than change so selecting the current score again
415 Removed: follows the same path. The hidden action field keeps the native POST contract. *)
415 Added: follows the same path. Defer the submit by one event-loop tick so the browser
416 Added: applies the radio value before form data is collected. *)
416 417 let feedback_choice event =
417 418 match closest "[data-hito-feedback-choice]" (Dom_html.eventTarget event) with
418 419 | None -> Js._true
@@ -423,9 +424,14 @@
423 424 match query_one form "[data-hito-feedback-action-value]" with
424 425 | None -> Js._true
425 426 | Some hidden ->
426 Removed: hidden##setAttribute (Js.string "value") (Js.string "next");
427 Removed: ignore (Js.Unsafe.meth_call form "requestSubmit" [||]);
428 Removed: Js._false))
427 Added: ignore
428 Added: (Dom_html.window##setTimeout
429 Added: (Js.wrap_callback (fun () ->
430 Added: hidden##setAttribute (Js.string "value")
431 Added: (Js.string "next");
432 Added: ignore (Js.Unsafe.meth_call form "requestSubmit" [||])))
433 Added: (Js.number_of_float 0.));
434 Added: Js._true))
429 435
430 436 (* The exercise dropdown navigates the moment its selection changes. It lives in
431 437 a GET form ([data-hito-exercise-form]) that submits to the workout path. The