michael-s-molina commented on pull request #16851:
URL: https://github.com/apache/superset/pull/16851#issuecomment-927784633


   > > @geido If I'm not mistaken when the user removes a filter, it only marks 
that filter as deleted but the form values are preserved. If that's the case, 
why do we need the `undoFormValues` state? Can't we just use the original form?
   > 
   > @michael-s-molina I checked that and it appears that when the filter is 
removed the form is also cleaned up. You won't have the most recent state of 
the form, hence I am storing it on removal and reapplying the values on undo.
   
   Do you know where the form is being cleared? This is the handler for the 
delete action and it's only marking it as removed. 
   
   ```
   export const createHandleTabEdit = (
     setRemovedFilters: (
       value:
         | ((
             prevState: Record<string, FilterRemoval>,
           ) => Record<string, FilterRemoval>)
         | Record<string, FilterRemoval>,
     ) => void,
     setSaveAlertVisible: Function,
     addFilter: Function,
   ) => (filterId: string, action: 'add' | 'remove') => {
     const completeFilterRemoval = (filterId: string) => {
       // 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 },
       }));
     };
   
     if (action === 'remove') {
       // first set up the timer to completely remove it
       const timerId = window.setTimeout(
         () => completeFilterRemoval(filterId),
         REMOVAL_DELAY_SECS * 1000,
       );
       // mark the filter state as "removal in progress"
       setRemovedFilters(removedFilters => ({
         ...removedFilters,
         [filterId]: { isPending: true, timerId },
       }));
       setSaveAlertVisible(false);
     } else if (action === 'add') {
       addFilter();
     }
   };
   ```


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