From: Mischa POSLAWSKY Date: Thu, 6 Jan 2022 18:23:29 +0000 (+0100) Subject: word/edit: search button toggles empty input X-Git-Tag: v1.13~43 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/98181d5e59c9ea4c5c84665ed8892af8011e30ad word/edit: search button toggles empty input Minimal javascript to make hiding work as expected. --- diff --git a/word/editor.js b/word/editor.js index aeab4cc..0e54c62 100644 --- a/word/editor.js +++ b/word/editor.js @@ -1,4 +1,17 @@ document.addEventListener('DOMContentLoaded', () => { + document.querySelectorAll('#search').forEach(p => { + let [input, button] = p.children; + button.onclick = e => { + if (input.value && input.offsetWidth > 50) { + return true; // bubble to submit + } + // make visible first + input.focus(); + e.preventDefault(); + return false; + }; + }); + document.querySelectorAll('.multiinput > input[id]').forEach(el => { el.oninput = e => { if (e.target.value == '') return;