@linzjs/step-ag-grid 22.2.2 → 22.2.4

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "22.2.2",
5
+ "version": "22.2.4",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -24,12 +24,19 @@ const BooleanCellRenderer = (props: CustomCellEditorProps) => {
24
24
  };
25
25
  }, [api, column, node.rowIndex]);
26
26
 
27
+ const isDisabled = !fnOrVar(colDef?.editable, props);
28
+
27
29
  return (
28
- <div className={clsx("ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper", { "ag-checked": props.value })}>
30
+ <div
31
+ className={clsx("ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper", {
32
+ "ag-checked": props.value,
33
+ "ag-disabled": isDisabled,
34
+ })}
35
+ >
29
36
  <input
30
37
  type="checkbox"
31
38
  className="ag-input-field-input ag-checkbox-input"
32
- disabled={!fnOrVar(colDef?.editable, props)}
39
+ disabled={isDisabled}
33
40
  ref={inputRef}
34
41
  checked={value}
35
42
  onChange={() => {}}
@@ -40,7 +47,15 @@ const BooleanCellRenderer = (props: CustomCellEditorProps) => {
40
47
  if (!onValueChange) return;
41
48
  const params = props?.colDef?.cellEditorParams as GridEditBooleanEditorProps<any> | undefined;
42
49
  if (!params) return;
43
- const selectedRows = [data];
50
+ // The data cannot be relied upon if grid changed whilst editing, data will be stale
51
+ // So I get the data from the node itself which will be up to date.
52
+ const selectedRows: { id: string | number }[] = [];
53
+ api.forEachNode((n) => {
54
+ if (n.data.id === data.id) {
55
+ selectedRows.push(n.data);
56
+ }
57
+ });
58
+
44
59
  const checked = !value;
45
60
  onValueChange(checked);
46
61
  params.onClick({ selectedRows, selectedRowIds: selectedRows.map((r) => r.id), checked }).then();