michael-s-molina commented on a change in pull request #16154:
URL: https://github.com/apache/superset/pull/16154#discussion_r727293437



##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.tsx
##########
@@ -249,28 +279,69 @@ export function FiltersConfigModal({
 
   const handleCancel = () => {
     const changed = form.getFieldValue('changed');
-    if (unsavedFiltersIds.length > 0 || form.isFieldsTouched() || changed) {
+    const initialOrder = buildFilterGroup(getInitialFilterHierarchy()).flat();
+    const didChangeOrder =
+      orderedFilters.flat().length !== initialOrder.length ||
+      orderedFilters.flat().some((val, index) => val !== initialOrder[index]);
+    if (
+      unsavedFiltersIds.length > 0 ||
+      form.isFieldsTouched() ||
+      changed ||
+      didChangeOrder
+    ) {
       setSaveAlertVisible(true);
     } else {
       handleConfirmCancel();
     }
   };
+  const onRearrage = (dragIndex: number, targetIndex: number) => {
+    const newOrderedFilter = orderedFilters.map(group => [...group]);
+
+    const removed = newOrderedFilter.splice(dragIndex, 1)[0];
+    newOrderedFilter.splice(targetIndex, 0, removed);
+    setOrderedFilters(newOrderedFilter);
+  };
+  const handleFilterHierarchyChange = useCallback(
+    (filterId: string, parentFilter?: { value: string; label: string }) => {
+      const index = filterHierarchy.findIndex(item => item.id === filterId);
+      const newState = [...filterHierarchy];
+      newState.splice(index, 1, {
+        id: filterId,
+        parentId: parentFilter ? parentFilter.value : null,
+      });
+      setFilterHierarchy(newState);
+      setOrderedFilters(buildFilterGroup(newState));
+    },
+    [setFilterHierarchy, setOrderedFilters, filterHierarchy],
+  );
 
   const onValuesChange = useMemo(
-    () =>
-      debounce((changes: any, values: NativeFiltersForm) => {

Review comment:
       Debouncing was added because we had a performance problem updating the 
form values every time a user typed a character while filling the filter name. 
We can only remove it if we provide an alternative solution for this problem.




-- 
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