From 2c51c7a3a11e345f48ee061e5dfbfd0fed79b801 Mon Sep 17 00:00:00 2001 From: Ramakrishna Chilaka <49393831+RamakrishnaChilaka@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:31:43 +0530 Subject: [PATCH] Update public/components/MDSEnabledComponent/MDSEnabledComponent.tsx Co-authored-by: SuZhou-Joe Signed-off-by: Ramakrishna Chilaka <49393831+RamakrishnaChilaka@users.noreply.github.com> Signed-off-by: Ramakrishna Chilaka --- .../MDSEnabledComponent/MDSEnabledComponent.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx index 305b16840..e1c58e22f 100644 --- a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx +++ b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx @@ -37,16 +37,15 @@ export default class MDSEnabledComponent< export function useUpdateUrlWithDataSourceProperties() { const dataSourceMenuProps = useContext(DataSourceMenuContext); const { dataSourceId, dataSourceLabel, multiDataSourceEnabled } = dataSourceMenuProps; - if (multiDataSourceEnabled) { - // mds flag can't change while the app is loaded - const history = useHistory(); - useEffect(() => { + const history = useHistory(); + useEffect(() => { + if (multiDataSourceEnabled) { history.replace({ search: queryString.stringify({ dataSourceId, dataSourceLabel, }), }); - }, [dataSourceId, dataSourceLabel]); - } + } + }, [dataSourceId, dataSourceLabel, multiDataSourceEnabled]); }