@linzjs/step-ag-grid 28.1.0 → 28.1.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.
@@ -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]);