[OCaml] High Intensity Training Online
fix clear modal query state on cancel
Cancelling a delete or feedback modal closed it in place but left the query param (?delete=ID, ?feedback=start) in the URL, so a refresh re-opened it. On dismiss, replaceState to the dismiss link's href to drop that state.
lib/web/workout_client.ml
@@ -420,6 +420,14 @@
420
420
(match closest "dialog" dismiss with
421
421
| Some modal -> ignore (Js.Unsafe.meth_call modal "close" [||])
422
422
| None -> close_modal ());
423
Added:
(* Drop any query state (e.g. ?delete=ID) that opened this modal, so a
424
Added:
refresh does not re-open it. *)
425
Added:
(match href dismiss with
426
Added:
| Some url ->
427
Added:
Dom_html.window##.history##replaceState
428
Added:
Js.null (Js.string "")
429
Added:
(Js.some (Js.string url))
430
Added:
| None -> ());
423
431
Js._false
424
432
| None -> (
425
433
match closest "[data-hito-confirm-accept]" target with
@@ -447,9 +455,15 @@
447
455
Js._false
448
456
| None -> (
449
457
match closest "[data-hito-feedback-dismiss]" target with
450
Removed:
| Some _ ->
458
Added:
| Some dismiss ->
451
459
Dom.preventDefault event;
452
460
close_feedback_modal ();
461
Added:
(match href dismiss with
462
Added:
| Some url ->
463
Added:
Dom_html.window##.history##replaceState
464
Added:
Js.null (Js.string "")
465
Added:
(Js.some (Js.string url))
466
Added:
| None -> ());
453
467
Js._false
454
468
| None -> Js._true)
455
469