kgabryje commented on a change in pull request #18793:
URL: https://github.com/apache/superset/pull/18793#discussion_r810058323



##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
##########
@@ -241,61 +172,23 @@ export const createHandleRemoveItem =
           ) => Record<string, FilterRemoval>)
         | Record<string, FilterRemoval>,
     ) => void,
-    setSaveAlertVisible: Function,
     setOrderedFilters: (
-      val: string[][] | ((prevState: string[][]) => string[][]),
+      val: string[] | ((prevState: string[]) => string[]),
     ) => void,
-    setFilterHierarchy: (
-      state:
-        | FilterHierarchy
-        | ((prevState: FilterHierarchy) => FilterHierarchy),
-    ) => void,
-    filterHierarchy: FilterHierarchy,
+    setSaveAlertVisible: Function,
   ) =>
   (filterId: string) => {
     const completeFilterRemoval = (filterId: string) => {
-      const buildNewFilterHierarchy = (hierarchy: FilterHierarchy) =>
-        hierarchy
-          .filter(nativeFilter => nativeFilter.id !== filterId)
-          .map(nativeFilter => {
-            const didRemoveParent = nativeFilter.parentId === filterId;
-            return didRemoveParent
-              ? { ...nativeFilter, parentId: null }
-              : nativeFilter;
-          });
       // the filter state will actually stick around in the form,
       // and the filterConfig/newFilterIds, but we use removedFilters
       // to mark it as removed.
       setRemovedFilters(removedFilters => ({
         ...removedFilters,
         [filterId]: { isPending: false },
       }));
-      // Remove the filter from the side tab and de-associate children
-      // in case we removed a parent.
-      setFilterHierarchy(prevFilterHierarchy =>
-        buildNewFilterHierarchy(prevFilterHierarchy),
+      setOrderedFilters((orderedFilters: string[]) =>
+        orderedFilters.filter(filter => !isEqual(filter, filterId)),

Review comment:
       ```suggestion
           orderedFilters.filter(filter => filter !== filterId),
   ```
   `isEqual` feels like a bit of an overkill for comparing 2 strings 🙂 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to