From 93a0859e87f0a115152e79e224fb42c10748c5fe Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Fri, 20 Oct 2023 02:23:53 +0530 Subject: [PATCH] fix: Unnecessary username validation on account profile form (#30677) --- .changeset/empty-files-know.md | 5 +++++ .../client/views/account/profile/AccountProfileForm.tsx | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/empty-files-know.md diff --git a/.changeset/empty-files-know.md b/.changeset/empty-files-know.md new file mode 100644 index 000000000000..5e6fb8f751b2 --- /dev/null +++ b/.changeset/empty-files-know.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fix unnecessary username validation on accounts profile form diff --git a/apps/meteor/client/views/account/profile/AccountProfileForm.tsx b/apps/meteor/client/views/account/profile/AccountProfileForm.tsx index ed97b95caae8..65b3a0967d49 100644 --- a/apps/meteor/client/views/account/profile/AccountProfileForm.tsx +++ b/apps/meteor/client/views/account/profile/AccountProfileForm.tsx @@ -66,6 +66,7 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle const { email, avatar, username } = watch(); const previousEmail = user ? getUserEmailAddress(user) : ''; + const previousUsername = user?.username || ''; const isUserVerified = user?.emails?.[0]?.verified ?? false; const mutateConfirmationEmail = useMutation({ @@ -87,6 +88,10 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle return; } + if (username === previousUsername) { + return; + } + if (!namesRegex.test(username)) { return t('error-invalid-username'); }