diff options
author | Joe Siltberg <git@joesiltberg.se> | 2019-11-15 08:49:55 +0100 |
---|---|---|
committer | Joe Siltberg <git@joesiltberg.se> | 2019-11-26 10:28:19 +0100 |
commit | dc3aac53bd187174c874ace463edc69ad94c08cf (patch) | |
tree | c06a2571ef20cb01a8f8da2122a11bd3e05ef788 /web/cobrands/fixamingata/js.js | |
parent | 0fab232fd05998e4780f9cae483d9f60f1a93d20 (diff) |
[FixaMinGata] Workaround for Chrome autocomplete issue
Diffstat (limited to 'web/cobrands/fixamingata/js.js')
-rw-r--r-- | web/cobrands/fixamingata/js.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/cobrands/fixamingata/js.js b/web/cobrands/fixamingata/js.js index ca5f772c4..5af23002a 100644 --- a/web/cobrands/fixamingata/js.js +++ b/web/cobrands/fixamingata/js.js @@ -1 +1,20 @@ fixmystreet.inspect_form_no_scroll_on_load = 1; + +// Chrome ignores autocomplete="off" on the title input, +// and incorrectly autocompletes it with the user's email address. +// For now we'll reset the title to empty if it contains +// an email address when the user has selected a category. +// Hopefully we can get rid of this eventually if Chrome changes +// its behaviour. +fixmystreet.fixChromeAutocomplete = function() { + let title = document.getElementById("form_title"); + + if (title) { + if (title.value == "" || + /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test(title.value)) { + title.value = ""; + } + } +} + +$(fixmystreet).on('report_new:category_change', fixmystreet.fixChromeAutocomplete); |