fix: Unnecessary queries when changing filter values (#16994)
This commit is contained in:
parent
5f73ca85d5
commit
c471a85170
|
|
@ -63,7 +63,8 @@ const FilterControls: FC<FilterControlsProps> = ({
|
|||
dataMask: dataMaskSelected[filter.id],
|
||||
}));
|
||||
return buildCascadeFiltersTree(filtersWithValue);
|
||||
}, [filterValues, dataMaskSelected]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [JSON.stringify(filterValues), dataMaskSelected]);
|
||||
const cascadeFilterIds = new Set(cascadeFilters.map(item => item.id));
|
||||
|
||||
const [filtersInScope, filtersOutOfScope] = useSelectFiltersInScope(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import {
|
|||
getChartMetadataRegistry,
|
||||
} from '@superset-ui/core';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { areObjectsEqual } from 'src/reduxUtils';
|
||||
import { isEqual, isEqualWith } from 'lodash';
|
||||
import { getChartDataRequest } from 'src/chart/chartAction';
|
||||
import Loading from 'src/components/Loading';
|
||||
import BasicErrorAlert from 'src/components/ErrorMessage/BasicErrorAlert';
|
||||
|
|
@ -105,10 +105,17 @@ const FilterValue: React.FC<FilterProps> = ({
|
|||
time_range,
|
||||
});
|
||||
const filterOwnState = filter.dataMask?.ownState || {};
|
||||
// TODO: We should try to improve our useEffect hooks to depend more on
|
||||
// granular information instead of big objects that require deep comparison.
|
||||
const customizer = (
|
||||
objValue: Partial<QueryFormData>,
|
||||
othValue: Partial<QueryFormData>,
|
||||
key: string,
|
||||
) => (key === 'url_params' ? true : undefined);
|
||||
if (
|
||||
!isRefreshing &&
|
||||
(!areObjectsEqual(formData, newFormData) ||
|
||||
!areObjectsEqual(ownState, filterOwnState) ||
|
||||
(!isEqualWith(formData, newFormData, customizer) ||
|
||||
!isEqual(ownState, filterOwnState) ||
|
||||
isDashboardRefreshing)
|
||||
) {
|
||||
setFormData(newFormData);
|
||||
|
|
|
|||
Loading…
Reference in New Issue