word/edit: search button toggles empty input
[sheet.git] / word / editor.js
index aeab4cc70bd6d14ecde326d4a40fd972bd5d2f07..0e54c62fe349a571727d1266af945bf12bddcbc2 100644 (file)
@@ -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;