Fix resetFilters not resetting power search
Reviewed By: antonk52 Differential Revision: D51351225 fbshipit-source-id: 4f0406b047ed1cc44d7de54976db2a422b07b7c0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
39d84e3bfc
commit
edc46dc2b1
@@ -38,7 +38,7 @@ const emptySelection: Selection = {
|
|||||||
|
|
||||||
type PersistedState = {
|
type PersistedState = {
|
||||||
/** Active search value */
|
/** Active search value */
|
||||||
searchExpression?: SearchExpressionTerm[];
|
searchExpression: SearchExpressionTerm[];
|
||||||
/** current selection, describes the index index in the datasources's current output (not window!) */
|
/** current selection, describes the index index in the datasources's current output (not window!) */
|
||||||
selection: {current: number; items: number[]};
|
selection: {current: number; items: number[]};
|
||||||
/** The currently applicable sorting, if any */
|
/** The currently applicable sorting, if any */
|
||||||
@@ -116,7 +116,7 @@ export type DataManagerState<T> = {
|
|||||||
sorting: Sorting<T> | undefined;
|
sorting: Sorting<T> | undefined;
|
||||||
selection: Selection;
|
selection: Selection;
|
||||||
autoScroll: boolean;
|
autoScroll: boolean;
|
||||||
searchExpression?: SearchExpressionTerm[];
|
searchExpression: SearchExpressionTerm[];
|
||||||
filterExceptions: string[] | undefined;
|
filterExceptions: string[] | undefined;
|
||||||
sideBySide: boolean;
|
sideBySide: boolean;
|
||||||
};
|
};
|
||||||
@@ -136,13 +136,13 @@ export const dataTableManagerReducer = produce<
|
|||||||
case 'reset': {
|
case 'reset': {
|
||||||
draft.columns = computeInitialColumns(config.defaultColumns);
|
draft.columns = computeInitialColumns(config.defaultColumns);
|
||||||
draft.sorting = undefined;
|
draft.sorting = undefined;
|
||||||
draft.searchExpression = undefined;
|
draft.searchExpression = [];
|
||||||
draft.selection = castDraft(emptySelection);
|
draft.selection = castDraft(emptySelection);
|
||||||
draft.filterExceptions = undefined;
|
draft.filterExceptions = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'resetFilters': {
|
case 'resetFilters': {
|
||||||
draft.searchExpression = undefined;
|
draft.searchExpression = [];
|
||||||
draft.filterExceptions = undefined;
|
draft.filterExceptions = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ export const dataTableManagerReducer = produce<
|
|||||||
}
|
}
|
||||||
case 'setSearchExpression': {
|
case 'setSearchExpression': {
|
||||||
getFlipperLib().logger.track('usage', 'data-table:filter:power-search');
|
getFlipperLib().logger.track('usage', 'data-table:filter:power-search');
|
||||||
draft.searchExpression = action.searchExpression;
|
draft.searchExpression = action.searchExpression ?? [];
|
||||||
draft.filterExceptions = undefined;
|
draft.filterExceptions = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ export function createInitialState<T>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let searchExpression = config.initialSearchExpression;
|
let searchExpression = config.initialSearchExpression ?? [];
|
||||||
if (prefs?.searchExpression?.length) {
|
if (prefs?.searchExpression?.length) {
|
||||||
searchExpression = prefs.searchExpression;
|
searchExpression = prefs.searchExpression;
|
||||||
}
|
}
|
||||||
@@ -506,12 +506,12 @@ export function getValueAtPath(obj: Record<string, any>, keyPath: string): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function computeDataTableFilter(
|
export function computeDataTableFilter(
|
||||||
searchExpression: SearchExpressionTerm[] | undefined,
|
searchExpression: SearchExpressionTerm[],
|
||||||
powerSearchProcessors: PowerSearchOperatorProcessorConfig,
|
powerSearchProcessors: PowerSearchOperatorProcessorConfig,
|
||||||
treatUndefinedValuesAsMatchingFiltering: boolean = false,
|
treatUndefinedValuesAsMatchingFiltering: boolean = false,
|
||||||
) {
|
) {
|
||||||
return function dataTableFilter(item: any) {
|
return function dataTableFilter(item: any) {
|
||||||
if (!searchExpression || !searchExpression.length) {
|
if (!searchExpression.length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return searchExpression.every((searchTerm) => {
|
return searchExpression.every((searchTerm) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user