╭ changed ──────────╮ │src/embed/script.js│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │52 return control ? [control] : Array.from(grid.querySelectorAll(`[data-focus-id="${id}"]`)); │ │53 } │ │54 │ │55 +// whether an input's caret sits past its last character, with nothing selected │ │56 +function caretAtEnd(input) { │ │57 + return input.selectionStart === input.value.length && input.selectionEnd === input.value.length;│ │58 +} │ │59 + │ │60 function focusedNativeScroll() { │ │61 const id = grid.dataset.focusId; │ │62 if (!id) return null; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │380 wasmInstance.exports._tick(minRows(), maxCols()); │ │381 } │ │382 return; │ │383 + } else if (tag === "INPUT" && !document.activeElement.form && !document.activeElement.readOnly &&│ │384 + (event.key === "Tab" && !event.shiftKey || │ │385 + event.key === "ArrowRight" && caretAtEnd(document.activeElement))) { │ │386 + // an input outside a form (a search box) reaches the widgets │ │387 + // beside it: Tab, and ArrowRight once the caret is at the end. │ │388 + // blurred first, so the next key isn't the input's; the tick │ │389 + // refocuses it if the TUI focus stayed. │ │390 + event.preventDefault(); │ │391 + document.activeElement.blur(); │ │392 + wasmInstance.exports._onKeyDown(event.keyCode); │ │393 + wasmInstance.exports._tick(minRows(), maxCols()); │ │394 + return; │ │395 } else if (tag === "INPUT" && (event.key === "ArrowUp" || event.key === "ArrowDown")) { │ │396 // up/down moves between widgets; left/right stay in the input │ │397 document.activeElement.blur(); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯