From 98181d5e59c9ea4c5c84665ed8892af8011e30ad Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 6 Jan 2022 19:23:29 +0100 Subject: [PATCH] word/edit: search button toggles empty input Minimal javascript to make hiding work as expected. --- word/editor.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; -- 2.30.0