Thank you for reporting this bug. We will make it our priority to review this report.
GXT SimpleComboBox: mismatch between selected item and index
I have a problem with GXT SimpleComboBox which I'm not sure is a bug or a (unexpected) feature. I have the example code below, which should work out of the box if you put it inside onModuleLoad() of your GWT entry point.
I add 10 items to the combo box and whenever I select one of them I get a matching item and item index in the Log.info() statements. However, when one of the items is selected and the combo box loses focus because I temporarily switch to another window (using the Mac version of Alt-Tab) the combo box expands with a single item (the currently selected one). This is illustrated in the following figure
When I go back to the browser window (where the combo box is displayed), the combo box remains selected and expanded with a single item (as in the figure). If I press Enter the Log.info() prints the correct item (Item 5) but not the correct item index (0). It seems that the combo box ListStore suddenly contains only a single item instead of 10.
I do not understand this behavior. If anyone has some ideas about this I would be very glad to hear about it.
final SimpleComboBox<String> comboBox
= new SimpleComboBox<String>(new LabelProvider<String>()
public String getLabel(String s)
for(int i = 0; i < 10; ++i)
comboBox.getStore().add("Item " + i);
public void onSelection(SelectionEvent<String> event)
String item = event.getSelectedItem();
Log.info("selectedItem: " + item);
Log.info("selectedIndex: " + comboBox.getStore().indexOf(item));
From the image, it appears that the store is filtered down to the item being typed in, yet I see setTriggerAction(ALL) in your code - this seems inconsistent.
If the store is being filtered, the ListStore will only report indexOf on visible items. This is ideal for most of the use cases involving the store, since data widgets like the Grid, ListView, or ComboBox should only care about the visible set of items. Similarly, store.get(i) will return a matching item from the indexOf value.
If the store is *not* being filtered, the index shouldn't be zero (as you noted), but the screenshot shouldn't show just one item.
It could be worth adding an event handler on StoreFilterEvents that that come from the store, and look at the stack trace to see what is causing that filter to occur even though you have setTriggerAction(ALL). The only filter being added within ComboBox is inside the ComboBox cell, and that is when the query is performed - with triggerAction=ALL, clicking on the trigger (ComboBoxCell.onTriggerClick) should show all items.
There is a delayed query that also invokes doQuery, run on each key up, to try to match the keys the user has entered - this only should happen with each keystroke, with a minimal delay. But since you've described the list shrinking only on focus from another window, I'm not entirely sure this is the cause.