From 346b2ad0a10a2534016e532ce18ef65c9fca373d Mon Sep 17 00:00:00 2001 From: Rohan Chaturvedi Date: Fri, 19 Jul 2024 16:58:50 +0530 Subject: [PATCH] fix: credential picker filter logic (#298) --- frontend/components/syncing/ProviderCredentialPicker.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/components/syncing/ProviderCredentialPicker.tsx b/frontend/components/syncing/ProviderCredentialPicker.tsx index 7b6487e8..238589c8 100644 --- a/frontend/components/syncing/ProviderCredentialPicker.tsx +++ b/frontend/components/syncing/ProviderCredentialPicker.tsx @@ -41,8 +41,11 @@ export const ProviderCredentialPicker = (props: { ? credentials.filter((cred) => cred.provider?.id === providerFilter) : credentials + const credentialMatchesFilter = + credential && providerFilter ? credential.provider?.id === providerFilter : true + useEffect(() => { - if (setDefault && filteredCredentials.length > 0 && !credential) + if (setDefault && filteredCredentials.length > 0 && !credentialMatchesFilter) setCredential(filteredCredentials[0]) // eslint-disable-next-line react-hooks/exhaustive-deps }, [providerFilter, filteredCredentials, setDefault])