@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/package.json
CHANGED
|
@@ -639,7 +639,24 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
639
639
|
const onFilterChanged = useMemo(
|
|
640
640
|
() =>
|
|
641
641
|
debounce(() => {
|
|
642
|
-
|
|
642
|
+
// This is terrible, but there's no other way for me to check whether a filter has changed the grid
|
|
643
|
+
const getDisplayedRowsHash = () => {
|
|
644
|
+
const arr: any[] = [];
|
|
645
|
+
gridApi?.forEachNodeAfterFilter((rowNode) => {
|
|
646
|
+
arr.push(rowNode.id);
|
|
647
|
+
});
|
|
648
|
+
return arr.join("|");
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
if (gridApi) {
|
|
652
|
+
const hasFocusedCell = gridApi.getFocusedCell();
|
|
653
|
+
const preHash = hasFocusedCell && getDisplayedRowsHash();
|
|
654
|
+
gridApi.onFilterChanged();
|
|
655
|
+
const postHash = hasFocusedCell && getDisplayedRowsHash();
|
|
656
|
+
// Ag-grid has a bug where if a focused cell comes into view after a filter the filter loses focus
|
|
657
|
+
// So the focus is cleared to prevent this
|
|
658
|
+
preHash !== postHash && gridApi.clearFocusedCell();
|
|
659
|
+
}
|
|
643
660
|
}, 200),
|
|
644
661
|
[gridApi],
|
|
645
662
|
);
|
|
@@ -255,7 +255,14 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
|
|
|
255
255
|
);
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
type KeysOfType<TObject, TValue> = {
|
|
259
|
+
[K in keyof TObject]: TObject[K] extends TValue ? K : never;
|
|
260
|
+
}[keyof TObject];
|
|
261
|
+
|
|
262
|
+
const GridFilterLessThan = (props: {
|
|
263
|
+
field: KeysOfType<ITestRow, number | null | undefined>;
|
|
264
|
+
text: string;
|
|
265
|
+
}): ReactElement => {
|
|
259
266
|
const [value, setValue] = useState<number>();
|
|
260
267
|
|
|
261
268
|
const filter = useCallback(
|