From a2bdad3ce02e25a01476f537b14e4aefdd4e6585 Mon Sep 17 00:00:00 2001 From: Jakob Vase Date: Sun, 19 Jan 2025 14:28:44 +0100 Subject: [PATCH] fix: only prevent default for `tab` if it replaces something --- lean4-unicode-input-component/package.json | 2 +- lean4-unicode-input-component/src/index.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lean4-unicode-input-component/package.json b/lean4-unicode-input-component/package.json index c9677ea23..c0e750361 100644 --- a/lean4-unicode-input-component/package.json +++ b/lean4-unicode-input-component/package.json @@ -1,6 +1,6 @@ { "name": "@leanprover/unicode-input-component", - "version": "0.1.0", + "version": "0.1.1", "description": "Typescript support for contenteditable divs with the Unicode input support of the Lean 4 theorem prover", "scripts": { "watch": "tsc --watch", diff --git a/lean4-unicode-input-component/src/index.ts b/lean4-unicode-input-component/src/index.ts index 62c5e8a19..957eb13e6 100644 --- a/lean4-unicode-input-component/src/index.ts +++ b/lean4-unicode-input-component/src/index.ts @@ -187,9 +187,12 @@ export class InputAbbreviationRewriter implements AbbreviationTextSource { }) textInput.addEventListener('keydown', async (ev: KeyboardEvent) => { - if (ev.key === 'Tab') { + if (ev.key === 'Tab' && this.rewriter.getTrackedAbbreviations().size > 0) { await this.rewriter.replaceAllTrackedAbbreviations() this.updateState() + // Don't send event to any other listeners, it was handled here. + ev.stopImmediatePropagation() + // Don't move focus to the next element. ev.preventDefault() } })