You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2025/01/15 18:59:30 UTC
(superset) 02/02: fix(RangeFilterPlugin): Manage state correctly
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch alexandrusoare/refactor/filter-numerical-range
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 53e686567a8879b691a0ccb6ac464d518438490c
Author: Diego Pucci <di...@gmail.com>
AuthorDate: Wed Jan 15 19:59:11 2025 +0100
fix(RangeFilterPlugin): Manage state correctly
---
.../FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx | 5 ++++-
.../src/filters/components/Range/RangeFilterPlugin.tsx | 10 +++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
index ccf763e393..aae734f215 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
@@ -1249,7 +1249,10 @@ const FiltersConfigForm = (
rules={[
{
validator: () => {
- if (formFilter?.defaultDataMask?.filterState?.value) {
+ if (
+ formFilter?.defaultDataMask?.filterState?.value !==
+ undefined
+ ) {
// requires managing the error as the DefaultValue
// component does not use an Antdesign compatible input
const formValidationFields = form.getFieldsError();
diff --git a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
index e2b374a549..03acf33ff5 100644
--- a/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx
@@ -123,7 +123,6 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
const handleAfterChange = useCallback(
(value: [number, number]): void => {
const { lower, upper } = getBounds(value);
- setValue(value);
setDataMask({
extraFormData: getRangeExtraFormData(col, lower, upper),
filterState: {
@@ -139,19 +138,19 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
const updatedValue: [number, number] = [...value];
if (enableSingleExactValue) {
- handleAfterChange([newValue, newValue]);
+ setValue([newValue, newValue]);
return;
}
if (enableSingleMinValue && index === minIndex) {
updatedValue[minIndex] = Math.min(newValue, updatedValue[maxIndex]);
- handleAfterChange(updatedValue);
+ setValue(updatedValue);
return;
}
if (enableSingleMaxValue && index === maxIndex) {
updatedValue[maxIndex] = Math.max(newValue, updatedValue[minIndex]);
- handleAfterChange(updatedValue);
+ setValue(updatedValue);
return;
}
@@ -162,7 +161,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
} else {
updatedValue[index] = newValue;
}
- handleAfterChange(updatedValue);
+ setValue(updatedValue);
};
useEffect(() => {
@@ -189,6 +188,7 @@ export default function RangeFilterPlugin(props: PluginFilterRangeProps) {
} else if (enableSingleExactValue) {
filterStateValue = [minMax[minIndex], minMax[minIndex]];
}
+ setValue(value);
handleAfterChange(filterStateValue);
}, [
enableSingleMaxValue,