Browse Source

Moving disableBrowserAutocomplete to WidgetUtil and change widgets to use it (#12020)

* Add autocomplete prevention to DateField

Autocomplete popup will interfere DateField's own popup

* Adding disableBrowserAutocomplete(..) in WidgetUtil

* Change VComboBox to use WidgetUtil.disableBrowserAutocomplete(..)

* Change to use WidgetUtil.disableBrowserAutocomplete(..)

* Change VFilterSelect to use WidgetUtil.disableBrowserAutocomplete(..)

* Adding WidgetUtil.disableBrowserAutocomplete to VTextualDate

* Adding missing import

* Adding missing import
tags/8.12.0.alpha1
Tatu Lund 4 years ago
parent
commit
06947c6f90
No account linked to committer's email address

+ 22
- 0
client/src/main/java/com/vaadin/client/WidgetUtil.java View File

import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.ErrorLevel; import com.vaadin.shared.ui.ErrorLevel;
import com.vaadin.shared.util.SharedUtil; import com.vaadin.shared.util.SharedUtil;
return indicator; return indicator;
} }
} }

public static void disableBrowserAutocomplete(TextBox textBox) {
/*-
* Stop the browser from showing its own suggestion popup.
*
* Using an invalid value instead of "off" as suggested by
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
*
* Leaving the non-standard Safari options autocapitalize and
* autocorrect untouched since those do not interfere in the same
* way, and they might be useful in a combo box where new items are
* allowed.
*/
if (BrowserInfo.get().isChrome()) {
// Chrome supports "off" and random number does not work with
// Chrome
textBox.getElement().setAttribute("autocomplete", "off");
} else {
textBox.getElement().setAttribute("autocomplete", Math.random() + "");
}
}
} }

+ 3
- 0
client/src/main/java/com/vaadin/client/ui/VAbstractTextualDate.java View File

import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.LocaleNotLoadedException; import com.vaadin.client.LocaleNotLoadedException;
import com.vaadin.client.LocaleService; import com.vaadin.client.LocaleService;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.aria.HandlesAriaCaption; import com.vaadin.client.ui.aria.HandlesAriaCaption;
import com.vaadin.client.ui.aria.HandlesAriaInvalid; import com.vaadin.client.ui.aria.HandlesAriaInvalid;
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
addDomHandler(this, KeyDownEvent.getType()); addDomHandler(this, KeyDownEvent.getType());
} }
// Stop the browser from showing its own suggestion popup.
WidgetUtil.disableBrowserAutocomplete(text);
add(text); add(text);
publishJSHelpers(getElement()); publishJSHelpers(getElement());
} }

+ 1
- 18
client/src/main/java/com/vaadin/client/ui/VComboBox.java View File

* @since 7.6.4 * @since 7.6.4
*/ */
public FilterSelectTextBox() { public FilterSelectTextBox() {
/*-
* Stop the browser from showing its own suggestion popup.
*
* Using an invalid value instead of "off" as suggested by
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
*
* Leaving the non-standard Safari options autocapitalize and
* autocorrect untouched since those do not interfere in the same
* way, and they might be useful in a combo box where new items are
* allowed.
*/
if (BrowserInfo.get().isChrome()) {
// Chrome supports "off" and random number does not work with
// Chrome
getElement().setAttribute("autocomplete", "off");
} else {
getElement().setAttribute("autocomplete", Math.random() + "");
}
WidgetUtil.disableBrowserAutocomplete(this);
} }


/** /**

+ 2
- 17
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java View File

* @since 7.6.4 * @since 7.6.4
*/ */
public FilterSelectTextBox() { public FilterSelectTextBox() {
/*-
* Stop the browser from showing its own suggestion popup.
*
* Using an invalid value instead of "off" as suggested by
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
*
* Leaving the non-standard Safari options autocapitalize and
* autocorrect untouched since those do not interfere in the same
* way, and they might be useful in a combo box where new items are
* allowed.
*/
if (BrowserInfo.get().isChrome()) {
// Chrome supports "off" and random number does not work with Chrome
getElement().setAttribute("autocomplete", "off");
} else {
getElement().setAttribute("autocomplete", Math.random() + "");
}
// Stop the browser from showing its own suggestion popup.
WidgetUtil.disableBrowserAutocomplete(this);
} }


/** /**

+ 3
- 0
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextualDate.java View File

import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.LocaleNotLoadedException; import com.vaadin.client.LocaleNotLoadedException;
import com.vaadin.client.LocaleService; import com.vaadin.client.LocaleService;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.SubPartAware;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.aria.HandlesAriaCaption; import com.vaadin.client.ui.aria.HandlesAriaCaption;
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
addDomHandler(this, KeyDownEvent.getType()); addDomHandler(this, KeyDownEvent.getType());
} }
// Stop the browser from showing its own suggestion popup.
WidgetUtil.disableBrowserAutocomplete(text);
add(text); add(text);
} }



Loading…
Cancel
Save