diff --git a/templates/zerver/login.html b/templates/zerver/login.html index 55c3bc6e47..313b782707 100644 --- a/templates/zerver/login.html +++ b/templates/zerver/login.html @@ -109,7 +109,7 @@ page can be easily identified in it's respective JavaScript file. --> {% if email %} autofocus {% endif %} required /> - + {% else %} {% include "two_factor/_wizard_forms.html" %} diff --git a/templates/zerver/register.html b/templates/zerver/register.html index 231ab31791..89e8a6a2d4 100644 --- a/templates/zerver/register.html +++ b/templates/zerver/register.html @@ -136,7 +136,7 @@ Form is validated both client-side using jquery-validation (see signup.js) and s
- + {{ _('Enter your LDAP/Active Directory password.') }} @@ -149,7 +149,7 @@ Form is validated both client-side using jquery-validation (see signup.js) and s data-min-length="{{password_min_length}}" data-min-guesses="{{password_min_guesses}}" required /> - + {% if full_name %} {{ _('This is used for mobile applications and other tools that require a password.') }} diff --git a/templates/zerver/reset_confirm.html b/templates/zerver/reset_confirm.html index d5cfd739a0..8a8c02ce38 100644 --- a/templates/zerver/reset_confirm.html +++ b/templates/zerver/reset_confirm.html @@ -34,7 +34,7 @@ maxlength="100" data-min-length="{{password_min_length}}" data-min-guesses="{{password_min_guesses}}" autofocus required /> - + {% if form.new_password1.errors %} {% for error in form.new_password1.errors %}
{{ error }}
@@ -53,7 +53,7 @@ - + {% if form.new_password2.errors %} {% for error in form.new_password2.errors %}
{{ error }}
diff --git a/web/src/common.ts b/web/src/common.ts index ac9ac166f6..9d9e6342b3 100644 --- a/web/src/common.ts +++ b/web/src/common.ts @@ -172,4 +172,11 @@ export function setup_password_visibility_toggle( e.stopPropagation(); toggle_password_visibility(password_field_id, password_selector, tippy_tooltips); }); + $(password_selector).on("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + e.stopPropagation(); + toggle_password_visibility(password_field_id, password_selector, tippy_tooltips); + } + }); } diff --git a/web/templates/dialog_change_password.hbs b/web/templates/dialog_change_password.hbs index 0818be23a2..7b7745f66a 100644 --- a/web/templates/dialog_change_password.hbs +++ b/web/templates/dialog_change_password.hbs @@ -2,7 +2,7 @@
- + @@ -11,7 +11,7 @@ - +
diff --git a/web/tests/common.test.js b/web/tests/common.test.js index 537391e02c..53984d5bfa 100644 --- a/web/tests/common.test.js +++ b/web/tests/common.test.js @@ -234,7 +234,13 @@ run_test("show password", () => { assert.ok(!$(password_selector).hasClass(absent_class)); } - const ev = { + const click_ev = { + preventDefault() {}, + stopPropagation() {}, + }; + + const key_ev = { + key: "Enter", preventDefault() {}, stopPropagation() {}, }; @@ -242,15 +248,23 @@ run_test("show password", () => { set_attribute("password"); common.setup_password_visibility_toggle("#id_password", password_selector); - const handler = $(password_selector).get_on_handler("click"); + const click_handler = $(password_selector).get_on_handler("click"); - handler(ev); + const key_handler = $(password_selector).get_on_handler("keydown"); + + click_handler(click_ev); check_assertion("text", "fa-eye", "fa-eye-slash"); - handler(ev); + click_handler(click_ev); check_assertion("password", "fa-eye-slash", "fa-eye"); - handler(ev); + key_handler(key_ev); + check_assertion("text", "fa-eye", "fa-eye-slash"); + + key_handler(key_ev); + check_assertion("password", "fa-eye-slash", "fa-eye"); + + click_handler(click_ev); common.reset_password_toggle_icons("#id_password", password_selector); check_assertion("password", "fa-eye-slash", "fa-eye");