From aaf92a6ef5b47fb0a155227e70225928166b3bdd Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Thu, 29 Dec 2022 13:04:04 +0800 Subject: [PATCH] fix(console): close deletion modal on connector changed (#2749) --- packages/console/src/pages/ConnectorDetails/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/console/src/pages/ConnectorDetails/index.tsx b/packages/console/src/pages/ConnectorDetails/index.tsx index 05f2ba5ed..27af97854 100644 --- a/packages/console/src/pages/ConnectorDetails/index.tsx +++ b/packages/console/src/pages/ConnectorDetails/index.tsx @@ -1,9 +1,9 @@ import type { ConnectorResponse } from '@logto/schemas'; import { ConnectorType } from '@logto/schemas'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { toast } from 'react-hot-toast'; import { Trans, useTranslation } from 'react-i18next'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useLocation, useNavigate, useParams } from 'react-router-dom'; import useSWR, { useSWRConfig } from 'swr'; import Back from '@/assets/images/back.svg'; @@ -39,6 +39,7 @@ const getConnectorsPathname = (isSocial: boolean) => `/connectors/${isSocial ? ConnectorsTabs.Social : ConnectorsTabs.Passwordless}`; const ConnectorDetails = () => { + const { pathname } = useLocation(); const { connectorId } = useParams(); const { mutate: mutateGlobal } = useSWRConfig(); const [isDeleted, setIsDeleted] = useState(false); @@ -55,6 +56,10 @@ const ConnectorDetails = () => { const isSocial = data?.type === ConnectorType.Social; const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false); + useEffect(() => { + setIsDeleteAlertOpen(false); + }, [pathname]); + const onDeleteClick = async () => { if (!isSocial || !inUse) { await handleDelete();