From 78e82b77040f2057271fdcbdfd5bf539beb51db6 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 6 Sep 2022 11:24:40 +0200 Subject: [PATCH] TermInput: Handle spaces between quotes correctly --- asset/js/widget/TermInput.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/asset/js/widget/TermInput.js b/asset/js/widget/TermInput.js index 8ab26fc9..34ec69a9 100644 --- a/asset/js/widget/TermInput.js +++ b/asset/js/widget/TermInput.js @@ -143,13 +143,13 @@ define(["../notjQuery", "BaseInput"], function ($, BaseInput) { } let input = event.target; - switch (event.key) { - case '"': - case "'": - if (this.ignoreSpaceUntil === null) { - this.ignoreSpaceUntil = event.key; - this.ignoreSpaceSince = input.selectionStart - 1; - } + let firstChar = this.readPartialTerm(input).charAt(0); + + if (firstChar === "'" || firstChar === '"') { + if (this.ignoreSpaceUntil === null) { + this.ignoreSpaceUntil = firstChar; + this.ignoreSpaceSince = input.selectionStart - 1; + } } } @@ -198,6 +198,9 @@ define(["../notjQuery", "BaseInput"], function ($, BaseInput) { // Register current input value, otherwise it's not included this.exchangeTerm(); event.preventDefault(); + + this.ignoreSpaceUntil = null; + this.ignoreSpaceSince = null; } } }