@linzjs/step-ag-grid 21.2.0 → 21.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/step-ag-grid.cjs.js +17 -1
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +17 -1
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/contexts/GridContextProvider.tsx +18 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +8 -1
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -5023,7 +5023,23 @@ const GridContextProvider = (props) => {
|
|
|
5023
5023
|
}
|
|
5024
5024
|
}, []);
|
|
5025
5025
|
const onFilterChanged = useMemo(() => debounce(() => {
|
|
5026
|
-
|
|
5026
|
+
// This is terrible, but there's no other way for me to check whether a filter has changed the grid
|
|
5027
|
+
const getDisplayedRowsHash = () => {
|
|
5028
|
+
const arr = [];
|
|
5029
|
+
gridApi?.forEachNodeAfterFilter((rowNode) => {
|
|
5030
|
+
arr.push(rowNode.id);
|
|
5031
|
+
});
|
|
5032
|
+
return arr.join("|");
|
|
5033
|
+
};
|
|
5034
|
+
if (gridApi) {
|
|
5035
|
+
const hasFocusedCell = gridApi.getFocusedCell();
|
|
5036
|
+
const preHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5037
|
+
gridApi.onFilterChanged();
|
|
5038
|
+
const postHash = hasFocusedCell && getDisplayedRowsHash();
|
|
5039
|
+
// Ag-grid has a bug where if a focused cell comes into view after a filter the filter loses focus
|
|
5040
|
+
// So the focus is cleared to prevent this
|
|
5041
|
+
preHash !== postHash && gridApi.clearFocusedCell();
|
|
5042
|
+
}
|
|
5027
5043
|
}, 200), [gridApi]);
|
|
5028
5044
|
const addExternalFilter = (filter) => {
|
|
5029
5045
|
externalFilters.current.push(filter);
|