Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha User
SelectHandler is not consuming 'Space' when space bar is used.
GXT 3.1.4
1. Use space bar to select the 'Select Combo' button
2. The ComboBox field takes focus, the value is replaced with a space
Repeat for the TextField.
Expected Behaviour: The Input Field takes focus and the space is consumed by the event.
Code:
public class SelectHandlerSample implements EntryPoint { ComboValueProperties properties = GWT.create(ComboValueProperties.class);
interface ComboValueProperties extends PropertyAccess<ComboValue> {
ModelKeyProvider<ComboValue> key();
LabelProvider<ComboValue> name();
}
class ComboValue {
String name;
int key;
public ComboValue(String name, int key) {
super();
this.name = name;
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
}
/**
* This is the entry point method.
*/
public void onModuleLoad() {
VerticalLayoutContainer container = new VerticalLayoutContainer();
ComboValue defaultValue = new ComboValue("Option 1", 1);
ListStore<ComboValue> store = new ListStore<>(properties.key());
store.add(defaultValue);
store.add(new ComboValue("Option 2", 2));
store.add(new ComboValue("Option 3", 3));
final ComboBox<ComboValue> values = new ComboBox<>(store, properties.name());
values.setValue(defaultValue);
values.setSelectOnFocus(true);
TextButton button = new TextButton("Select Combo");
button.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
values.focus();
}
});
final TextField field = new TextField();
field.setValue("Some text");
field.setSelectOnFocus(true);
TextButton button2 = new TextButton("Select Field");
button2.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
field.focus();
}
});
FlexTable table = new FlexTable();
table.setWidget(0, 0, values);
table.setWidget(0, 1, button);
table.setWidget(1, 0, field);
table.setWidget(1, 1, button2);
table.setWidth("300px");
container.add(table, new VerticalLayoutData(-1, -1));
RootPanel.get().add(container);
button.focus();
}
}
Update : Was able to stop this behaviour by placing a DeferredCommand call around the focus call.
Code:
button.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
values.focus();
}
});
}
});