From 75b1869a31733faaf04a1db6eef547a18657a0b9 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 16 May 2022 10:14:33 +0200 Subject: [PATCH] BaseInput: Only move focus if suggestion list is not visible `! this.completer.hasSuggestions()` ensures that the suggestion list is not visible, otherwise pressing ArrowDown or ArrowUp to select the suggested options will change the focus of the terms. This will cause the selected suggestion to overwrite the existing term at position 0. Or if a term is being edited and something is selected from the suggestion list, a new duplicate term is added because the focus has moved again. --- asset/js/widget/BaseInput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asset/js/widget/BaseInput.js b/asset/js/widget/BaseInput.js index 85c537b2..d0cd867b 100644 --- a/asset/js/widget/BaseInput.js +++ b/asset/js/widget/BaseInput.js @@ -791,7 +791,7 @@ define(["../notjQuery", "Completer"], function ($, Completer) { break; case 'ArrowUp': if (this.isTermDirectionVertical() && this.hasTerms() - && (this.completer === null || ! this.completer.isBeingCompleted(input)) + && (this.completer === null || ! this.completer.isBeingCompleted(input) && ! this.completer.hasSuggestions()) ) { event.preventDefault(); this.moveFocusBackward(); @@ -799,7 +799,7 @@ define(["../notjQuery", "Completer"], function ($, Completer) { break; case 'ArrowDown': if (this.isTermDirectionVertical() && this.hasTerms() - && (this.completer === null || ! this.completer.isBeingCompleted(input)) + && (this.completer === null || ! this.completer.isBeingCompleted(input) && ! this.completer.hasSuggestions()) ) { event.preventDefault(); this.moveFocusForward();