Threaded View
-
28 Nov 2012 5:04 AM #1
GXT SimpleComboBox: mismatch between selected item and index
GXT SimpleComboBox: mismatch between selected item and index
Hi,
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
combo.png
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.
Thanks,
Ralph
Code:final SimpleComboBox<String> comboBox = new SimpleComboBox<String>(new LabelProvider<String>() { @Override public String getLabel(String s) { return s; } }); comboBox.setForceSelection(true); comboBox.setEmptyText("Select item..."); comboBox.setTriggerAction(ComboBoxCell.TriggerAction.ALL); for(int i = 0; i < 10; ++i) { comboBox.getStore().add("Item " + i); } comboBox.addSelectionHandler(new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) { String item = event.getSelectedItem(); Log.info("selectedItem: " + item); Log.info("selectedIndex: " + comboBox.getStore().indexOf(item)); } }); RootPanel.get().add(comboBox);
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote