From 099c0ad6f637d05a11ccdcc0dd7c9ead0351bb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 26 Jan 2022 10:05:22 +0100 Subject: [PATCH] Fixes input dialog for password field (#1934) Fixes an javascript error in the create user dialog where the "event" from the password field is a simple string, no event. --- gradle/changelog/password_field.yaml | 2 ++ .../ui-components/src/forms/PasswordConfirmation.tsx | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 gradle/changelog/password_field.yaml diff --git a/gradle/changelog/password_field.yaml b/gradle/changelog/password_field.yaml new file mode 100644 index 0000000000..4d807d3e70 --- /dev/null +++ b/gradle/changelog/password_field.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Password field in "Create User" dialog and other ((#1934)[https://github.com/scm-manager/scm-manager/pull/1934]) diff --git a/scm-ui/ui-components/src/forms/PasswordConfirmation.tsx b/scm-ui/ui-components/src/forms/PasswordConfirmation.tsx index ed699d9358..5aeeb8ea5d 100644 --- a/scm-ui/ui-components/src/forms/PasswordConfirmation.tsx +++ b/scm-ui/ui-components/src/forms/PasswordConfirmation.tsx @@ -58,7 +58,13 @@ const PasswordConfirmation: FC = ({ passwordChanged, passwordValidat setPasswordConfirmationFailed(password !== newConfirmedPassword); }; - const handlePasswordChange = (newPassword: string) => { + const handlePasswordChange = (event: React.ChangeEvent | string) => { + let newPassword; + if (typeof event === "string") { + newPassword = event; + } else { + newPassword = event.target.value; + } setPasswordConfirmationFailed(newPassword !== confirmedPassword); setPassword(newPassword); setPasswordValid(validatePassword(newPassword)); @@ -70,7 +76,7 @@ const PasswordConfirmation: FC = ({ passwordChanged, passwordValidat handlePasswordChange(event.target.value)} + onChange={event => handlePasswordChange(event)} value={password} validationError={!passwordValid} errorMessage={t("password.passwordInvalid")}