This is an automated email from the ASF dual-hosted git repository.

kgabryje pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c01c13  fix(native-filters): Fix "undefined" error after editing a 
filter (#14984)
8c01c13 is described below

commit 8c01c13d90df93112a0c3e6d82b0db623418093c
Author: Kamil Gabryjelski <[email protected]>
AuthorDate: Fri Jun 4 15:15:37 2021 +0200

    fix(native-filters): Fix "undefined" error after editing a filter (#14984)
    
    * fix(native-filters): Fix "undefined" error after editing a filter
    
    * Remove console log
---
 .../src/dashboard/actions/nativeFilters.ts         | 26 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/superset-frontend/src/dashboard/actions/nativeFilters.ts 
b/superset-frontend/src/dashboard/actions/nativeFilters.ts
index 23ce35d..e01a5a6 100644
--- a/superset-frontend/src/dashboard/actions/nativeFilters.ts
+++ b/superset-frontend/src/dashboard/actions/nativeFilters.ts
@@ -85,11 +85,19 @@ export const setFilterConfiguration = (
     endpoint: `/api/v1/dashboard/${id}`,
   });
 
+  const mergedFilterConfig = filterConfig.map(filter => {
+    const oldFilter = oldFilters[filter.id];
+    if (!oldFilter) {
+      return filter;
+    }
+    return { ...oldFilter, ...filter };
+  });
+
   try {
     const response = await updateDashboard({
       json_metadata: JSON.stringify({
         ...metadata,
-        native_filter_configuration: filterConfig,
+        native_filter_configuration: mergedFilterConfig,
       }),
     });
     dispatch(
@@ -99,12 +107,20 @@ export const setFilterConfiguration = (
     );
     dispatch({
       type: SET_FILTER_CONFIG_COMPLETE,
-      filterConfig,
+      filterConfig: mergedFilterConfig,
     });
-    dispatch(setDataMaskForFilterConfigComplete(filterConfig, oldFilters));
+    dispatch(
+      setDataMaskForFilterConfigComplete(mergedFilterConfig, oldFilters),
+    );
   } catch (err) {
-    dispatch({ type: SET_FILTER_CONFIG_FAIL, filterConfig });
-    dispatch({ type: SET_DATA_MASK_FOR_FILTER_CONFIG_FAIL, filterConfig });
+    dispatch({
+      type: SET_FILTER_CONFIG_FAIL,
+      filterConfig: mergedFilterConfig,
+    });
+    dispatch({
+      type: SET_DATA_MASK_FOR_FILTER_CONFIG_FAIL,
+      filterConfig: mergedFilterConfig,
+    });
   }
 };
 

Reply via email to