Skip to content

Commit

Permalink
Close Comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Jan 22, 2025
1 parent 1d4a9ac commit 00f73cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/components/Comparison/Comparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down
8 changes: 6 additions & 2 deletions src/components/SearchControls/SearchControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ export const SearchControls: FC<Props> = ({ 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('');
Expand All @@ -72,6 +74,8 @@ export const SearchControls: FC<Props> = ({ submitSearch, changeSegment, clearVa
const onResetButtonClick = () => {
clearValuesAndResetControls();
resetPreviewContent();
resetFullDisplayComponentType();
resetSelectedInstances();
hasSearchParams && setSearchParams({});
hasSearchParams && setNavigationState({});
setAnnouncementMessage(formatMessage({ id: 'ld.aria.filters.reset.announce' }));
Expand All @@ -92,7 +96,7 @@ export const SearchControls: FC<Props> = ({ submitSearch, changeSegment, clearVa
<FormattedMessage id={isVisibleFilters ? 'ld.searchAndFilter' : 'ld.search'} />
</h2>
<Button
className='close-ctl'
className="close-ctl"
onClick={() => setIsSearchPaneCollapsed(true)}
ariaLabel={formatMessage({ id: 'ld.aria.searchPane.close' })}
>
Expand Down

0 comments on commit 00f73cc

Please sign in to comment.