From 90c1af1151c42114c9f3ec26f2beca73c21fa9e6 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 22 Jan 2019 16:31:14 +0000 Subject: [PATCH] [FIX] web: no chrome autocompete on many2one widget For editing many2one fields (and partially many2many) most widget show an autocompleting list of targeted records. They thus have `autocomplete="off"` to prevent browser completion. But chromium has an history of breaking `autocomplete="off"`, see: - https://caniuse.com/#search=autocomplete - https://crbug.com/468153 - https://crbug.com/587466 - https://crbug.com/914451 - https://crbug.com/923895 It seems that since chromium 71, the heuristic to ignore `autocomplete="off"` has become more aggressive and for example if there is at least 3 fields like an address in a page, chromium will ignore `autocomplete="off"` for the fields like an address. So for example the eidting the many2One field with placeholder "Country" in a contact page now has a browser autocomplete menu that is: - hidding the many2one autocomplete - going to save empty country it appeared visually filled if the autocomplete result was selected. With this changeset, the placeholder in the many2one instance is interspersed with U+FEFF charcters (ZERO WIDTH NO-BREAK SPACE) so the browser does enable the autocomplete feature by force. This should thus remove the issue (until it is fixed by chromium) in the case of field named "Country" or matching other regexes in this file: https://github.com/chromium/chromium/blob/cdb1b2073f12/components/autofill/core/common/autofill_regex_constants.cc U+FEFF has been chosen instead of more recommended characters because other have been shown erroneous for printing in some windows configuration (see cb2a3afa7). 10.0 version of #30439 opw-1930588 closes #30439 closes #30449 --- addons/web/static/src/js/views/form_relational_widgets.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 2ca483eac2b..1dd61553ca2 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -264,6 +264,12 @@ var FieldMany2One = common.AbstractField.extend(common.CompletionFieldMixin, com } }); + // avoid ignoring autocomplete="off" by obfuscating placeholder, see #30439 + if (this.$input.attr('placeholder')) { + this.$input.attr('placeholder', function (index, val) { + return val.split('').join('\ufeff'); + }); + } var isSelecting = false; // autocomplete this.$input.autocomplete({