From d24dd97a0335b2fbd28d1b9bfed9c8f5d0d1f7af Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 14:57:35 +0100 Subject: Update common library --- lib/elements/popup.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/elements/popup.ml') diff --git a/lib/elements/popup.ml b/lib/elements/popup.ml index bf97559..28c414e 100755 --- a/lib/elements/popup.ml +++ b/lib/elements/popup.ml @@ -37,7 +37,6 @@ let create: submit_btn end; - let container = match form with | None -> El.div | Some _ -> El.form @@ -73,6 +72,16 @@ let create: let () = El.append_children (Document.body G.document) [ el ] in + (* Add the focus to the first input element inside the form *) + let () = match form with + | Some (_, el) when El.is_el el -> + begin match (El.find_by_tag_name ~root:el (Jstr.v "input")) with + | [] -> () + | hd::_ -> El.set_has_focus true hd + end + | _ -> () + in + (* Event handler *) let close_event = Evr.on_el Ev.click -- cgit v1.2.3