Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix of #1042
At the moment of pressing Enter key while Error being shown,
index
(1) which comes as an argument equals to empty string.At the same time
this.selected
equals toundefined
(2) here.This happens because (3) here it gets
undefined
value every time non-existing index inserted, so at the time Error message shown, this value persists, which leads to assertion throw (4) here -> (5) here.To prevent this from happening I decided to re-assign (!)
this.selected
value if needed by checking with nullish coalescing operator.This way, if user presses Enter without entering non-existing index beforehand (i.e. sending empty string), he gets the first (default) option selected, as it was before the change.
However, if Error been shown,
this.selected
will get-1
value, which is number (so assert pass + no negative effect) and allows user to press Enter as much as he would like to (nothing happens, expected behavior; alternative to-1
could be assigningthis.rawDefault
, then second Enter press just chooses first option available).At the same time this allows to get back to selection by just pressing arrows or entering number.