From b8ea4800c5081117af8689a4a13924e9004db11b Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Fri, 31 May 2024 13:09:09 +0800 Subject: [PATCH] fix(console): avoid rendering outdated role options (#5953) --- .../components/RolesTransfer/SourceRolesBox/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/console/src/components/RolesTransfer/SourceRolesBox/index.tsx b/packages/console/src/components/RolesTransfer/SourceRolesBox/index.tsx index 332399db2..1da49e842 100644 --- a/packages/console/src/components/RolesTransfer/SourceRolesBox/index.tsx +++ b/packages/console/src/components/RolesTransfer/SourceRolesBox/index.tsx @@ -45,7 +45,14 @@ function SourceRolesBox({ entityId, type, selectedRoles, onChange }: Props) { ...conditional(keyword && { search: `%${keyword}%` }), }); - const { data, error } = useSWR<[RoleResponse[], number], RequestError>(url); + const { data, error } = useSWR<[RoleResponse[], number], RequestError>(url, { + /** + * Always use the latest data to reflect the latest available roles. + * Using cached data before new data is loaded can result in roles that have been assigned or deleted being rendered in the list. + * If a deleted role is rendered in the list, it will cause the query requests for role scopes in the list items to return a 404 error. + */ + keepPreviousData: false, + }); const isLoading = !data && !error;