@linzjs/step-ag-grid 22.2.0 → 22.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/src/components/clickInputWhenContainingCellClicked.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +8 -13
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +8 -13
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/clickInputWhenContainingCellClicked.tsx +11 -14
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { CellClickedEvent } from "ag-grid-community";
|
|
2
|
+
import { fnOrVar } from "../utils/util";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
5
6
|
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
6
7
|
*/
|
|
7
|
-
export const clickInputWhenContainingCellClicked = (
|
|
8
|
+
export const clickInputWhenContainingCellClicked = (params: CellClickedEvent) => {
|
|
9
|
+
const { data, event, colDef } = params;
|
|
8
10
|
if (!data || !event) return;
|
|
9
11
|
|
|
12
|
+
if (fnOrVar(colDef.editable, params) === false) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
const element = event.target as Element;
|
|
11
17
|
// Already handled
|
|
12
18
|
if (["BUTTON", "INPUT"].includes(element?.tagName) && element.closest(".ag-cell-inline-editing")) return;
|
|
@@ -17,24 +23,15 @@ export const clickInputWhenContainingCellClicked = ({ data, event, colDef }: Cel
|
|
|
17
23
|
const colId = colDef.colId;
|
|
18
24
|
if (!colId) return;
|
|
19
25
|
|
|
20
|
-
const clickInput = (
|
|
26
|
+
const clickInput = () => {
|
|
21
27
|
const cell = row.querySelector(`[col-id='${colId}']`);
|
|
22
28
|
if (!cell) return;
|
|
23
29
|
|
|
24
30
|
const input = cell.querySelector("input, button");
|
|
25
|
-
if (!input)
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
// When clicking on a cell that is not editing, the cell changes to editing and the input/button ref becomes invalid
|
|
29
|
-
// So wait until the cell is in edit mode before sending the click
|
|
30
|
-
if (!input.ownerDocument.contains(input)) {
|
|
31
|
-
if (cnt !== 0) {
|
|
32
|
-
setTimeout(() => clickInput(cnt - 1));
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
31
|
+
if (!input) return;
|
|
32
|
+
|
|
36
33
|
input?.dispatchEvent(event);
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
setTimeout(
|
|
36
|
+
setTimeout(clickInput, 20);
|
|
40
37
|
};
|