@linzjs/step-ag-grid 28.1.0 → 28.1.2
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/utils/__tests__/testUtil.ts +8 -3
- package/dist/step-ag-grid.cjs +32 -0
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +32 -0
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +38 -0
- package/src/utils/__tests__/testUtil.ts +8 -3
|
@@ -135,8 +135,13 @@ export const findCellContains = async (
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
export const selectCell = async (rowId: string | number, colId: string, within?: HTMLElement): Promise<void> => {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
await waitFor(
|
|
139
|
+
async () => {
|
|
140
|
+
const cell = await findCell(rowId, colId, within);
|
|
141
|
+
await user.click(cell);
|
|
142
|
+
},
|
|
143
|
+
{ timeout: 10000 },
|
|
144
|
+
);
|
|
140
145
|
};
|
|
141
146
|
|
|
142
147
|
export const editCell = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<void> => {
|
|
@@ -200,7 +205,7 @@ export const openAndClickMenuOption = async (
|
|
|
200
205
|
menuOptionText: string | RegExp,
|
|
201
206
|
within?: HTMLElement,
|
|
202
207
|
): Promise<void> => {
|
|
203
|
-
await
|
|
208
|
+
await selectCell(rowId, colId, within);
|
|
204
209
|
await clickMenuOption(menuOptionText);
|
|
205
210
|
};
|
|
206
211
|
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2756,6 +2756,30 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
|
|
|
2756
2756
|
};
|
|
2757
2757
|
|
|
2758
2758
|
agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModule]);
|
|
2759
|
+
let timeOfLastSingleClick = 0;
|
|
2760
|
+
let lastClickColId;
|
|
2761
|
+
let lastClickRowIndex;
|
|
2762
|
+
const resetClickDebounce = () => {
|
|
2763
|
+
timeOfLastSingleClick = 0;
|
|
2764
|
+
lastClickColId = '';
|
|
2765
|
+
lastClickRowIndex = -1;
|
|
2766
|
+
};
|
|
2767
|
+
/**
|
|
2768
|
+
* If click is more than 200ms since last click return true.
|
|
2769
|
+
*/
|
|
2770
|
+
const clickDebounceSkipClick = (colId, rowIndex) => {
|
|
2771
|
+
const doubleClickMs = 200;
|
|
2772
|
+
if (Date.now() - timeOfLastSingleClick < doubleClickMs &&
|
|
2773
|
+
lastClickColId === colId &&
|
|
2774
|
+
lastClickRowIndex === rowIndex) {
|
|
2775
|
+
// Skipping double click due to single click edit
|
|
2776
|
+
return true;
|
|
2777
|
+
}
|
|
2778
|
+
timeOfLastSingleClick = Date.now();
|
|
2779
|
+
lastClickColId = colId;
|
|
2780
|
+
lastClickRowIndex = rowIndex;
|
|
2781
|
+
return false;
|
|
2782
|
+
};
|
|
2759
2783
|
/**
|
|
2760
2784
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2761
2785
|
*/
|
|
@@ -2994,6 +3018,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
2994
3018
|
* Handle double click edit
|
|
2995
3019
|
*/
|
|
2996
3020
|
const onCellDoubleClick = React.useCallback((event) => {
|
|
3021
|
+
if (clickDebounceSkipClick(event.colDef.colId, event.rowIndex)) {
|
|
3022
|
+
// the next click will be a single click, we want it to pass
|
|
3023
|
+
resetClickDebounce();
|
|
3024
|
+
return;
|
|
3025
|
+
}
|
|
2997
3026
|
const editable = fnOrVar(event.colDef?.editable, event);
|
|
2998
3027
|
if (editable && !invokeEditAction(event)) {
|
|
2999
3028
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
@@ -3005,6 +3034,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3005
3034
|
const onCellClicked = React.useCallback((event) => {
|
|
3006
3035
|
const editable = fnOrVar(event.colDef?.editable, event);
|
|
3007
3036
|
if ((editable && event.colDef.singleClickEdit) ?? singleClickEdit) {
|
|
3037
|
+
if (clickDebounceSkipClick(event.colDef.colId, event.rowIndex)) {
|
|
3038
|
+
return;
|
|
3039
|
+
}
|
|
3008
3040
|
void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
|
|
3009
3041
|
}
|
|
3010
3042
|
}, [singleClickEdit, startCellEditing]);
|