diff --git a/packages/manager/.changeset/pr-10947-fixed-1726507951785.md b/packages/manager/.changeset/pr-10947-fixed-1726507951785.md new file mode 100644 index 00000000000..8f9cc90912a --- /dev/null +++ b/packages/manager/.changeset/pr-10947-fixed-1726507951785.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +Flickering on the user profile page when updating the currently signed in user's username ([#10947](https://github.com/linode/manager/pull/10947)) diff --git a/packages/manager/src/queries/account/users.ts b/packages/manager/src/queries/account/users.ts index ac819e4bde3..ae720f52cb7 100644 --- a/packages/manager/src/queries/account/users.ts +++ b/packages/manager/src/queries/account/users.ts @@ -15,6 +15,7 @@ import type { Filter, Grants, Params, + Profile, ResourcePage, User, } from '@linode/api-v4'; @@ -65,11 +66,20 @@ export const useUpdateUserMutation = (username: string) => { accountQueries.users._ctx.user(user.username).queryKey, user ); - // If the currently logged in user updates their user + + // If the currently logged in user updates their user, we need to update the profile + // query to reflect the latest data. if (username === profile?.username) { - queryClient.invalidateQueries({ - queryKey: profileQueries.profile().queryKey, - }); + queryClient.setQueryData( + profileQueries.profile().queryKey, + (oldProfile) => { + if (!oldProfile) { + return; + } + + return { ...oldProfile, ...user }; + } + ); } }, });