Skip to content

Commit

Permalink
BaseInput: Only move focus if suggestion list is not visible
Browse files Browse the repository at this point in the history
`! 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.
  • Loading branch information
sukhwinder33445 committed Aug 29, 2022
1 parent bcadec9 commit 75b1869
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions asset/js/widget/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,15 +791,15 @@ 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();
}
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();
Expand Down

0 comments on commit 75b1869

Please sign in to comment.