Closed DarrenC closed 10 years ago
In fact, with a bit more investigation, this seems to be more an issue of the default enter key behaviour which does a form submission, rather than anything related to the GWT maps framework or the autocomplete button.
I'll close the issue and below I leave a workaround for blocking the enter key in the text box from submitting the form.
// Prevent Enter key presses from submitting the form in the departure city text box
tbPlaces.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER){
GWT.log("Blocking form submit for autocomplete text box");
event.preventDefault();
}
}
});
Hi, I've come across an issue while using the GWT-Maps places Autocomplete with a TextBox when it is contained in a Form.
If I hit enter while the cursor is in the textbox, then there is a warning message that pops up saying "GWT module 'showcase' may need to be recompiled". If the textbox is not contained in a form, then there is no warning message.
I first noticed this issue in an app I'm developing but can recreate in the latest Showcase Demo using the AutocompletePlacesMapWidget by adding a FormPanel to the page.
The issue seems to be reproducible whether there is text entered in the textbox or not, or even if there is a google places result returned and highlighted by pressing the down arrow to select it and then hitting enter. (In the final case, the map does update to show the result once the warning popup is closed).
I'm using version - 3.10.0-alpha-8-SNAPSHOT of the library.
Is using a Textbox with Autocomplete within a form a supported usecase?
My code is below from the AutocompletePlacesMapWidget.java. I've just added a FormPanel to the widget and also added a null check for the geomtry variable in case we don't find a place in the google search. Please let me know if you need anything more.