diff options
author | Artur Signell <artur@vaadin.com> | 2016-01-01 12:02:06 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-01-07 08:19:02 +0000 |
commit | af15d54e5a49491ebadb9748381a22239ebf8ff7 (patch) | |
tree | 14875bb93410404ef361faf959d526d6949ae412 /client | |
parent | 86969a99c2c3ac0389912dceaf3bad9477717fb1 (diff) | |
download | vaadin-framework-af15d54e5a49491ebadb9748381a22239ebf8ff7.tar.gz vaadin-framework-af15d54e5a49491ebadb9748381a22239ebf8ff7.zip |
Fixes exception when enter is pressed and there is nothing to select (#19149)
Change-Id: I8ff11e98bb4ec999d369ff5bcde0cb95290ed037
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VFilterSelect.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 99ebde1910..9459cc14a6 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1861,8 +1861,16 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, case KeyCodes.KEY_ENTER: if (!allowNewItem) { - onSuggestionSelected(currentSuggestions - .get(suggestionPopup.menu.getSelectedIndex())); + int selected = suggestionPopup.menu.getSelectedIndex(); + if (selected != -1) { + onSuggestionSelected(currentSuggestions.get(selected)); + } else { + // The way VFilterSelect is done, it handles enter and tab + // in exactly the same way so we close the popup in both + // cases even though we could leave it open when pressing + // enter + suggestionPopup.hide(); + } } else { // Handle addition of new items. suggestionPopup.menu.doSelectedItemAction(); |