fix ui reset filters on site id change (#2004)

This commit is contained in:
Delirium 2024-03-27 16:16:36 +01:00 committed by GitHub
parent 5556568fd3
commit 886ec45b7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,10 +11,12 @@ interface Props {
clearSearch: () => void;
appliedFilter: any;
savedSearch: any;
site: any;
}
const MainSearchBar = (props: Props) => {
const { appliedFilter } = props;
const { appliedFilter, site } = props;
const currSite = React.useRef(site)
const hasFilters = appliedFilter && appliedFilter.filters && appliedFilter.filters.size > 0;
const hasSavedSearch = props.savedSearch && props.savedSearch.exists();
const hasSearch = hasFilters || hasSavedSearch;
@ -22,6 +24,14 @@ const MainSearchBar = (props: Props) => {
// @ts-ignore
const originStr = window.env.ORIGIN || window.location.origin;
const isSaas = /app\.openreplay\.com/.test(originStr);
React.useEffect(() => {
if (site !== currSite.current && currSite.current !== undefined) {
console.debug('clearing filters due to project change')
props.clearSearch();
currSite.current = site
}
}, [site])
return (
<div className="flex items-center flex-wrap">
<div style={{ flex: 3, marginRight: '10px' }}>
@ -47,6 +57,7 @@ export default connect(
(state: any) => ({
appliedFilter: state.getIn(['search', 'instance']),
savedSearch: state.getIn(['search', 'savedSearch']),
site: state.getIn(['site', 'siteId']),
}),
{
clearSearch,