From aa18e57dfdf2bd0f626d7101ab712e6a0ff6dbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:05:56 +0200 Subject: Focus summary when editing existing. --- static/script.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'static/script.js') diff --git a/static/script.js b/static/script.js index 7f9291d7..5b6f561a 100644 --- a/static/script.js +++ b/static/script.js @@ -475,6 +475,10 @@ function place_in_edit_mode (event) { /* ---------------------------------------- */ + /* TODO add elements if the arent't already there + * Almost all should be direct children of '.event-body'. + * Biggest problem is generated fields relative order. + */ let descs = popup.getElementsByClassName("description"); if (descs.length === 1) { let description = descs[0]; @@ -515,6 +519,11 @@ function place_in_edit_mode (event) { article.replaceWith(wrappingForm); wrappingForm.appendChild(article); + /* this is for existing events. + * Newly created events aren't in the DOM tree yet, and can + * therefore not yet be focused */ + input.focus(); + } window.onload = function () { @@ -558,7 +567,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='summary']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } -- cgit v1.2.3