Skip to content

Commit

Permalink
[ES-1982] Fixed the issue where the validation was failed to change t…
Browse files Browse the repository at this point in the history
…he text on language change. (#456)

Signed-off-by: GurukiranP <[email protected]>
  • Loading branch information
gk-4VII authored Dec 10, 2024
1 parent fe161b7 commit 10a2e84
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
14 changes: 12 additions & 2 deletions signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => {
useEffect(() => {
const oldLanguage = previousLanguage;
setPreviousLanguage(i18n.language);
if (oldLanguage !== i18n.language && document.querySelector('input[aria-invalid="true"][name^="fullname"]')) {
methods.trigger(); // Manually trigger validation whenever the language changes

if (oldLanguage !== i18n.language) {
const invalidInput = Array.from(
document.querySelectorAll('input[aria-invalid="true"]')
).find((input) => {
const name = input.getAttribute("name") ?? ""; // Default to an empty string if null
return /fullname/i.test(name);
});

if (invalidInput) {
methods.trigger(); // Manually trigger validation whenever the language changes
}
}
}, [i18n.language]); // Trigger whenever `i18n.language` changes

Expand Down
13 changes: 11 additions & 2 deletions signup-ui/src/pages/SignUpPage/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,17 @@ export const SignUpPage = ({ settings }: SignUpPageProps) => {
useEffect(() => {
const oldLanguage = previousLanguage;
setPreviousLanguage(i18n.language);
if (oldLanguage !== i18n.language && document.querySelector('input[aria-invalid="true"][name^="fullname"]')) {
methods.trigger(); // Manually trigger validation whenever the language changes
if (oldLanguage !== i18n.language) {
const invalidInput = Array.from(
document.querySelectorAll('input[aria-invalid="true"]')
).find((input) => {
const name = input.getAttribute('name') ?? ''; // Default to an empty string if null
return /fullname/i.test(name);
});

if (invalidInput) {
methods.trigger(); // Manually trigger validation whenever the language changes
}
}
}, [i18n.language]); // Trigger whenever `i18n.language` changes

Expand Down

0 comments on commit 10a2e84

Please sign in to comment.