aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorIlya Ermakov <ilya403403@gmail.com>2015-03-12 20:19:36 +0300
committerVaadin Code Review <review@vaadin.com>2015-04-10 12:11:20 +0000
commitd175f53e44bb835139fd10097fed4cb8eee58870 (patch)
tree07556a080de7de3f92fbef283a1c380046305686 /client/src
parent6e494b16ab428d4d6f946b513d3fe004798149e2 (diff)
downloadvaadin-framework-d175f53e44bb835139fd10097fed4cb8eee58870.tar.gz
vaadin-framework-d175f53e44bb835139fd10097fed4cb8eee58870.zip
Set value selected by mouse when pressing Enter in ComboBox (#16981)
With this patch pressing Enter in ComboBox sets value selected by mouse. Selection by keyboard is not given higher priority. Change-Id: I2e5f610923a40f67be2c1504a004af0d431a67a3
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java50
1 files changed, 6 insertions, 44 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index c99ed49c91..d99779b7ec 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -454,7 +454,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
// Set the text.
setText(suggestion.getReplacementString());
- menu.updateKeyboardSelectedItem();
}
/*
@@ -739,13 +738,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
public class SuggestionMenu extends MenuBar implements SubPartAware,
LoadHandler {
- /**
- * Tracks the item that is currently selected using the keyboard. This
- * is need only because mouseover changes the selection and we do not
- * want to use that selection when pressing enter to select the item.
- */
- private MenuItem keyboardSelectedItem;
-
private VLazyExecutor delayedImageLoadExecutioner = new VLazyExecutor(
100, new ScheduledCommand() {
@@ -807,9 +799,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
if (enableDebug) {
debug("VFS.SM: setSuggestions(" + suggestions + ")");
}
- // Reset keyboard selection when contents is updated to avoid
- // reusing old, invalid data
- setKeyboardSelectedItem(null);
clearItems();
final Iterator<FilterSelectSuggestion> it = suggestions.iterator();
@@ -984,14 +973,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
- private MenuItem getKeyboardSelectedItem() {
- return keyboardSelectedItem;
- }
-
- public void setKeyboardSelectedItem(MenuItem menuItem) {
- keyboardSelectedItem = menuItem;
- }
-
/**
* @deprecated use {@link SuggestionPopup#selectFirstItem()} instead.
*/
@@ -1014,13 +995,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
/*
- * Sets the keyboard item as the current selected one.
- */
- void updateKeyboardSelectedItem() {
- setKeyboardSelectedItem(getSelectedItem());
- }
-
- /*
* Gets the height of one menu item.
*/
int getItemOffsetHeight() {
@@ -1787,25 +1761,13 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
break;
case KeyCodes.KEY_TAB:
case KeyCodes.KEY_ENTER:
- if (suggestionPopup.menu.getKeyboardSelectedItem() == null) {
- /*
- * Nothing selected using up/down. Happens e.g. when entering a
- * text (causes popup to open) and then pressing enter.
- */
- if (!allowNewItem) {
- onSuggestionSelected(currentSuggestions
- .get(suggestionPopup.menu.getSelectedIndex()));
- } else {
- // Handle addition of new items.
- suggestionPopup.menu.doSelectedItemAction();
- }
+
+ if (!allowNewItem) {
+ onSuggestionSelected(currentSuggestions
+ .get(suggestionPopup.menu.getSelectedIndex()));
} else {
- /*
- * Get the suggestion that was navigated to using up/down.
- */
- currentSuggestion = ((FilterSelectSuggestion) suggestionPopup.menu
- .getKeyboardSelectedItem().getCommand());
- onSuggestionSelected(currentSuggestion);
+ // Handle addition of new items.
+ suggestionPopup.menu.doSelectedItemAction();
}
event.stopPropagation();