Projet

Général

Profil

0001-misc-fix-email-autocorrect-behavior-when-pressing-en.patch

Valentin Deniaud, 11 mai 2021 17:29

Télécharger (1,93 ko)

Voir les différences:

Subject: [PATCH] misc: fix email autocorrect behavior when pressing enter
 (#50763)

 .../authentic2/js/email_domains_suggestions.js     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
src/authentic2/static/authentic2/js/email_domains_suggestions.js
66 66
  return weight;
67 67
}
68 68

  
69
var change_triggered = false;
70

  
69 71
$(function() {
70 72
  var $domain_hint_div;
71 73
  $('input[type=email]').on('change', function() {
74
    change_triggered = true;
72 75
    var $email_input = $(this);
73 76
    var suggested_domains = $(this).data('suggested-domains').split(':');
74 77
    var val = $email_input.val();
......
87 90
    }
88 91
    if (highest_ratio > 0.80 && highest_ratio < 1) {
89 92
      $domain_hint_div = $('div.field-live-hint')
90
      $domain_hint_div.find('button.action').on('click', function() {
93
      $domain_hint_div.find('button.action').off().on('click', function(event) {
94
        if(change_triggered && $domain_hint_div.is(':visible') && !event.screenX && !event.screenY) {
95
          // prevent applying the correction just after showing hint if enter key is used
96
          change_triggered = false;
97
          return false;
98
        }
99
        if(!$domain_hint_div.is(':visible')) {
100
          // allow submitting form with enter key if there is no hint
101
          return true;
102
        }
91 103
        $email_input.val($email_input.val().replace(/@.*/, '@' + $(this).data('suggestion')));
92 104
        $email_input.trigger('change');
93 105
        $domain_hint_div.hide();
94
-