diff --git a/src/components/[guild]/AddAndOrderRoles/hooks/useReorderRoles.ts b/src/components/[guild]/AddAndOrderRoles/hooks/useReorderRoles.ts index 71b5570b56..6af81175a5 100644 --- a/src/components/[guild]/AddAndOrderRoles/hooks/useReorderRoles.ts +++ b/src/components/[guild]/AddAndOrderRoles/hooks/useReorderRoles.ts @@ -32,10 +32,15 @@ const useReorderRoles = (onClose) => { ...oldData, // requirements, and rolePlatforms are not returned, so we need to spread older data too // Plus, we don't update all the roles, only the ones that changed, so this also retains those that weren't updated - roles: (oldData?.roles ?? []).map((prevRole) => ({ - ...prevRole, - ...(newRoles ?? []).find((newRole) => newRole.id === prevRole.id), - })), + roles: (oldData?.roles ?? []) + .map((prevRole) => ({ + ...prevRole, + ...(newRoles ?? []).find((newRole) => newRole.id === prevRole.id), + })) + .sort( + (role1, role2) => + (role1.position ?? Infinity) - (role2.position ?? Infinity) + ), }), { revalidate: false,