@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.
@@ -2754,6 +2754,30 @@ const usePostSortRowsHook = ({ setStaleGrid }) => {
2754
2754
  };
2755
2755
 
2756
2756
  ModuleRegistry.registerModules([AllCommunityModule]);
2757
+ let timeOfLastSingleClick = 0;
2758
+ let lastClickColId;
2759
+ let lastClickRowIndex;
2760
+ const resetClickDebounce = () => {
2761
+ timeOfLastSingleClick = 0;
2762
+ lastClickColId = '';
2763
+ lastClickRowIndex = -1;
2764
+ };
2765
+ /**
2766
+ * If click is more than 200ms since last click return true.
2767
+ */
2768
+ const clickDebounceSkipClick = (colId, rowIndex) => {
2769
+ const doubleClickMs = 200;
2770
+ if (Date.now() - timeOfLastSingleClick < doubleClickMs &&
2771
+ lastClickColId === colId &&
2772
+ lastClickRowIndex === rowIndex) {
2773
+ // Skipping double click due to single click edit
2774
+ return true;
2775
+ }
2776
+ timeOfLastSingleClick = Date.now();
2777
+ lastClickColId = colId;
2778
+ lastClickRowIndex = rowIndex;
2779
+ return false;
2780
+ };
2757
2781
  /**
2758
2782
  * Wrapper for AgGrid to add commonly used functionality.
2759
2783
  */
@@ -2992,6 +3016,11 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2992
3016
  * Handle double click edit
2993
3017
  */
2994
3018
  const onCellDoubleClick = useCallback((event) => {
3019
+ if (clickDebounceSkipClick(event.colDef.colId, event.rowIndex)) {
3020
+ // the next click will be a single click, we want it to pass
3021
+ resetClickDebounce();
3022
+ return;
3023
+ }
2995
3024
  const editable = fnOrVar(event.colDef?.editable, event);
2996
3025
  if (editable && !invokeEditAction(event)) {
2997
3026
  void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
@@ -3003,6 +3032,9 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3003
3032
  const onCellClicked = useCallback((event) => {
3004
3033
  const editable = fnOrVar(event.colDef?.editable, event);
3005
3034
  if ((editable && event.colDef.singleClickEdit) ?? singleClickEdit) {
3035
+ if (clickDebounceSkipClick(event.colDef.colId, event.rowIndex)) {
3036
+ return;
3037
+ }
3006
3038
  void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
3007
3039
  }
3008
3040
  }, [singleClickEdit, startCellEditing]);