[Canvas] Fixes filter clearing on undo/redo (#31859) (#31977)

* Added check to reset filters in 'setExpression'

* Removed filter reset from filter renderers' onDestroy handler

* Cleaned up setExpression

* Added TODO
This commit is contained in:
Catherine Liu 2019-02-25 21:17:58 -07:00 committed by GitHub
parent a0009fb446
commit a98e07d341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View file

@ -22,7 +22,6 @@ export const advancedFilter = () => ({
);
handlers.onDestroy(() => {
handlers.setFilter('');
ReactDOM.unmountComponentAtNode(domNode);
});
},

View file

@ -56,7 +56,6 @@ export const dropdownFilter = () => ({
);
handlers.onDestroy(() => {
handlers.setFilter('');
ReactDOM.unmountComponentAtNode(domNode);
});
},

View file

@ -37,7 +37,6 @@ export const timeFilter = () => ({
);
handlers.onDestroy(() => {
handlers.setFilter('');
ReactDOM.unmountComponentAtNode(domNode);
});
},

View file

@ -263,7 +263,18 @@ function setExpressionFn({ dispatch, getState }, expression, elementId, pageId,
// read updated element from state and fetch renderable
const updatedElement = getNodeById(getState(), elementId, pageId);
if (doRender === true) {
// reset element.filter if element is no longer a filter
// TODO: find a way to extract a list of filter renderers from the functions registry
if (
updatedElement.filter &&
!['dropdownControl', 'timefilterControl', 'exactly'].some(filter =>
updatedElement.expression.includes(filter)
)
) {
dispatch(setFilter('', elementId, pageId, doRender));
// setFilter will trigger a re-render so we can skip the fetch here
} else if (doRender === true) {
dispatch(fetchRenderable(updatedElement));
}
}