From 00f73cce7624687ded323dac9cd7d760b752b127 Mon Sep 17 00:00:00 2001 From: Siarhei Karol Date: Wed, 22 Jan 2025 10:37:13 +0300 Subject: [PATCH] Close Comparison --- src/components/Comparison/Comparison.tsx | 10 +++++++++- src/components/SearchControls/SearchControls.tsx | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/Comparison/Comparison.tsx b/src/components/Comparison/Comparison.tsx index 693e75a8..e10355d7 100644 --- a/src/components/Comparison/Comparison.tsx +++ b/src/components/Comparison/Comparison.tsx @@ -37,7 +37,15 @@ export const Comparison = () => { }); } - setPreviewContent(prev => prev.filter(({ id: prevId }) => prevId !== id)); + setPreviewContent(prev => { + const updatedPreviewContent = prev.filter(({ id: prevId }) => prevId !== id); + + if (!updatedPreviewContent.length) { + resetFullDisplayComponentType(); + } + + return updatedPreviewContent; + }); setSelectedInstances(prev => prev.filter(prevId => prevId !== id)); }; diff --git a/src/components/SearchControls/SearchControls.tsx b/src/components/SearchControls/SearchControls.tsx index 81b74193..4c0e0db8 100644 --- a/src/components/SearchControls/SearchControls.tsx +++ b/src/components/SearchControls/SearchControls.tsx @@ -46,8 +46,10 @@ export const SearchControls: FC = ({ submitSearch, changeSegment, clearVa setNavigationState, resetFacets: resetControls, setFacetsBySegments, + resetSelectedInstances, } = useSearchState(); - const { isSearchPaneCollapsed, setIsSearchPaneCollapsed, setIsAdvancedSearchOpen } = useUIState(); + const { isSearchPaneCollapsed, setIsSearchPaneCollapsed, setIsAdvancedSearchOpen, resetFullDisplayComponentType } = + useUIState(); const { resetPreviewContent } = useInputsState(); const [searchParams, setSearchParams] = useSearchParams(); const [announcementMessage, setAnnouncementMessage] = useState(''); @@ -72,6 +74,8 @@ export const SearchControls: FC = ({ submitSearch, changeSegment, clearVa const onResetButtonClick = () => { clearValuesAndResetControls(); resetPreviewContent(); + resetFullDisplayComponentType(); + resetSelectedInstances(); hasSearchParams && setSearchParams({}); hasSearchParams && setNavigationState({}); setAnnouncementMessage(formatMessage({ id: 'ld.aria.filters.reset.announce' })); @@ -92,7 +96,7 @@ export const SearchControls: FC = ({ submitSearch, changeSegment, clearVa