mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
password: Add debounce to password validation.
Added debouncing to the password input field to reduce lag when the password size is large. Fixes: #29429.
This commit is contained in:
committed by
Tim Abbott
parent
cb75feafbb
commit
1feb650284
@@ -1,4 +1,5 @@
|
|||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
import _ from "lodash";
|
||||||
import assert from "minimalistic-assert";
|
import assert from "minimalistic-assert";
|
||||||
import {z} from "zod";
|
import {z} from "zod";
|
||||||
|
|
||||||
@@ -24,10 +25,18 @@ $(() => {
|
|||||||
// was just reloaded due to a validation failure on the backend.
|
// was just reloaded due to a validation failure on the backend.
|
||||||
password_quality($password_field.val()!, $("#pw_strength .bar"), $password_field);
|
password_quality($password_field.val()!, $("#pw_strength .bar"), $password_field);
|
||||||
|
|
||||||
|
const debounced_password_quality = _.debounce((password_value: string, $field: JQuery) => {
|
||||||
|
password_quality(password_value, $("#pw_strength .bar"), $field);
|
||||||
|
}, 300);
|
||||||
|
|
||||||
$password_field.on("input", function () {
|
$password_field.on("input", function () {
|
||||||
// Update the password strength bar even if we aren't validating
|
const password_value = $(this).val()!;
|
||||||
// the field yet.
|
|
||||||
password_quality($(this).val()!, $("#pw_strength .bar"), $(this));
|
if (password_value.length > 30) {
|
||||||
|
debounced_password_quality(password_value, $(this));
|
||||||
|
} else {
|
||||||
|
password_quality(password_value, $("#pw_strength .bar"), $(this));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user