I'm proposing clearSuggestionSelection method to be added. This allows the developer to reset ReactTag's inner index state back to the initial value of -1. Resetting index has the effect of clearing the current suggestion selection.
Use case
Suggestions list is populated with most recent tags. Suggestion list is not filtered according the user input. Whatever the user types into the input field the suggestion list stays the same. User can select a suggested tag from the suggestion list or they can write a completely new tag.
Scenario where current behaviour is problematic
User types something into the input field.
Suggestion list is presented.
User uses arrow keys to select a suggestion.
But instead of adding the selected suggestion the user writes a custom tag.
User presses the delimiter key in order to add the custom tag they wrote.
Problem: ReactTags adds the tag that was selected earlier, not the one user had written into the input field.
See the GIF below for a visual demonstration. In it the user wants to add tag ‘hello’. Instead the previously selected tag ‘jäte’ is added.
How clearSuggestionSelection fixes the problem
By calling clearSuggestionSelection in onInput callback function the problem is solved. See the GIF below for a demonstration. In it the user is able to add tag ‘hello’ even though they selected tag ‘jäte’ previously.
Coverage remained the same at 100.0% when pulling 8a38a73943dfd4089ab66855c92fc836261d311f on response200:main into de5eb14454828d81ea401e928eef8b356d00fa5c on i-like-robots:main.
I'm proposing clearSuggestionSelection method to be added. This allows the developer to reset ReactTag's inner
index
state back to the initial value of-1
. Resettingindex
has the effect of clearing the current suggestion selection.Use case
Suggestions list is populated with most recent tags. Suggestion list is not filtered according the user input. Whatever the user types into the input field the suggestion list stays the same. User can select a suggested tag from the suggestion list or they can write a completely new tag.
Scenario where current behaviour is problematic
See the GIF below for a visual demonstration. In it the user wants to add tag ‘hello’. Instead the previously selected tag ‘jäte’ is added.
How clearSuggestionSelection fixes the problem
By calling
clearSuggestionSelection
inonInput
callback function the problem is solved. See the GIF below for a demonstration. In it the user is able to add tag ‘hello’ even though they selected tag ‘jäte’ previously.