Remove flashing on initializing datatable with filter
Summary: When filter is applied for the first time we shouldn't debounce to avoid "flashing" on datatable loading when it is first loaded without filter and then filter applied after 250ms. Changelog: Fixed flashing on opening datatable-based plugin with a filter. Reviewed By: timur-valiev Differential Revision: D36602929 fbshipit-source-id: 8bd33f50c92036f2a5565f636f4f2fbe69d900f2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8d07b7b644
commit
015be5ad83
@@ -339,11 +339,21 @@ export function DataTable<T extends object>(
|
||||
});
|
||||
useEffect(
|
||||
function updateFilter() {
|
||||
debouncedSetFilter(
|
||||
tableState.searchValue,
|
||||
tableState.useRegex,
|
||||
tableState.columns,
|
||||
);
|
||||
if (!dataSource.view.isFiltered) {
|
||||
dataSource.view.setFilter(
|
||||
computeDataTableFilter(
|
||||
tableState.searchValue,
|
||||
tableState.useRegex,
|
||||
tableState.columns,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
debouncedSetFilter(
|
||||
tableState.searchValue,
|
||||
tableState.useRegex,
|
||||
tableState.columns,
|
||||
);
|
||||
}
|
||||
},
|
||||
// Important dep optimization: we don't want to recalc filters if just the width or visibility changes!
|
||||
// We pass entire state.columns to computeDataTableFilter, but only changes in the filter are a valid cause to compute a new filter function
|
||||
|
||||
Reference in New Issue
Block a user