diff --git a/src/components/manage/Blocks/DetailedLink/View.jsx b/src/components/manage/Blocks/DetailedLink/View.jsx index efb7eaae..2f8fcfdb 100644 --- a/src/components/manage/Blocks/DetailedLink/View.jsx +++ b/src/components/manage/Blocks/DetailedLink/View.jsx @@ -1,10 +1,11 @@ import React from 'react'; -import { injectIntl } from 'react-intl'; +import { compose } from 'redux'; +import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { settings } from '~/config'; import cx from 'classnames'; import './style.css'; -import { useEffect } from 'react'; +import { deleteQueryParam } from 'volto-datablocks/actions'; const getPath = (url) => { if (!url) return ''; @@ -62,7 +63,22 @@ const View = (props) => { 'detailed-link-button display-inline-block', buttonClassname || '', )} - onClick={(e) => e.preventDefault} + onClick={(e) => { + if ( + props.discodata_query.search.facilityInspireId || + props.discodata_query.search.installationInspireId || + props.discodata_query.search.lcpInspireId + ) { + props.deleteQueryParam({ + queryParam: [ + 'facilityInspireId', + 'installationInspireId', + 'lcpInspireId', + ], + }); + } + return e.preventDefault; + }} to={getPath(detailedLink.path)} > {buttonTitle || detailedLink.title || 'Go'} @@ -76,4 +92,11 @@ const View = (props) => { ); }; -export default injectIntl(View); +export default compose( + connect( + (state, props) => ({ + discodata_query: state.discodata_query, + }), + { deleteQueryParam }, + ), +)(View); diff --git a/src/components/manage/Blocks/FiltersBlock/View.jsx b/src/components/manage/Blocks/FiltersBlock/View.jsx index ac1ca51f..0da3f5fc 100644 --- a/src/components/manage/Blocks/FiltersBlock/View.jsx +++ b/src/components/manage/Blocks/FiltersBlock/View.jsx @@ -1128,9 +1128,9 @@ const View = ({ content, ...props }) => { filterKey ].options.filter((option) => { if ( - state.filters[ + typeof state.filters[ state.filtersMeta[filterKey].queryToSet - ] && + ]?.filter === 'function' && !state.filters[ state.filtersMeta[filterKey].queryToSet ] diff --git a/src/components/manage/Blocks/NavigationBlock/View.jsx b/src/components/manage/Blocks/NavigationBlock/View.jsx index 889b6100..04fa0db2 100644 --- a/src/components/manage/Blocks/NavigationBlock/View.jsx +++ b/src/components/manage/Blocks/NavigationBlock/View.jsx @@ -12,6 +12,7 @@ import { getNavigationByParent, getBasePath, } from 'volto-tabsview/helpers'; +import { deleteQueryParam } from 'volto-datablocks/actions'; const View = ({ content, ...props }) => { const { data } = props; @@ -58,6 +59,19 @@ const View = ({ content, ...props }) => { active={state.activeItem === url} onClick={() => { history.push(`${url}${props.query}`); + if ( + props.discodata_query.search.facilityInspireId || + props.discodata_query.search.installationInspireId || + props.discodata_query.search.lcpInspireId + ) { + props.deleteQueryParam({ + queryParam: [ + 'facilityInspireId', + 'installationInspireId', + 'lcpInspireId', + ], + }); + } }} /> ); @@ -73,14 +87,18 @@ const View = ({ content, ...props }) => { }; export default compose( - connect((state, props) => ({ - query: state.router.location.search, - content: - state.prefetch?.[state.router.location.pathname] || state.content.data, - pathname: state.router.location.pathname, - navigation: getNavigationByParent( - state.navigation.items, - props.data?.parent?.value, - ), - })), + connect( + (state, props) => ({ + query: state.router.location.search, + content: + state.prefetch?.[state.router.location.pathname] || state.content.data, + pathname: state.router.location.pathname, + discodata_query: state.discodata_query, + navigation: getNavigationByParent( + state.navigation.items, + props.data?.parent?.value, + ), + }), + { deleteQueryParam }, + ), )(View);