Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

Commit 453f589

Browse files
committed
cleanup
1 parent e58c6ba commit 453f589

2 files changed

Lines changed: 4 additions & 32 deletions

File tree

components/lib/datatable/BodyCell.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ChevronDownIcon } from '../icons/chevrondown';
88
import { ChevronRightIcon } from '../icons/chevronright';
99
import { PencilIcon } from '../icons/pencil';
1010
import { TimesIcon } from '../icons/times';
11-
import { OverlayService } from '../overlayservice/OverlayService';
1211
import { Ripple } from '../ripple/Ripple';
1312
import { DomHandler, IconUtils, ObjectUtils, classNames } from '../utils/Utils';
1413
import { RowCheckbox } from './RowCheckbox';
@@ -21,8 +20,6 @@ export const Cell = (props) => {
2120
const [styleObjectState, setStyleObjectState] = React.useState({});
2221
const elementRef = React.useRef(null);
2322
const keyHelperRef = React.useRef(null);
24-
const overlayEventListener = React.useRef(null);
25-
const selfClick = React.useRef(false);
2623
const focusTimeout = React.useRef(null);
2724
const initFocusTimeout = React.useRef(null);
2825
const editingRowDataStateRef = React.useRef(null);
@@ -58,9 +55,9 @@ export const Cell = (props) => {
5855
};
5956

6057
const isIgnoredElement = (element) => {
61-
const isCellEditor = (el) => el.getAttribute && el.getAttribute('data-pr-is-overlay');
58+
const isOverlay = (el) => el.getAttribute && el.getAttribute('data-pr-is-overlay');
6259

63-
return isCellEditor(element) || DomHandler.getParents(element).find((el) => isCellEditor(el));
60+
return isOverlay(element) || DomHandler.getParents(element).find((el) => isOverlay(el));
6461
};
6562

6663
const [bindDocumentClickListener, unbindDocumentClickListener] = useEventListener({
@@ -69,8 +66,6 @@ export const Cell = (props) => {
6966
if (!isIgnoredElement(e.target) && isOutsideClicked(e.target)) {
7067
switchCellToViewMode(e, true);
7168
}
72-
73-
selfClick.current = false;
7469
},
7570
options: true,
7671
when: isEditable()
@@ -121,10 +116,7 @@ export const Cell = (props) => {
121116
setTimeout(() => {
122117
setEditingState(false);
123118
unbindDocumentClickListener();
124-
OverlayService.off('overlay-click', overlayEventListener.current);
125-
overlayEventListener.current = null;
126119
editingRowDataStateRef.current = null;
127-
selfClick.current = false;
128120
}, 1);
129121
};
130122

@@ -177,7 +169,7 @@ export const Cell = (props) => {
177169
};
178170

179171
const onClick = (event) => {
180-
props.onClick(event, getCellCallbackParams(event), isEditable(), editingState, setEditingState, selfClick, props.column, bindDocumentClickListener, overlayEventListener, isOutsideClicked);
172+
props.onClick(event, getCellCallbackParams(event), isEditable(), editingState, setEditingState, props.column, bindDocumentClickListener);
181173
};
182174

183175
const onMouseDown = (event) => {
@@ -278,8 +270,6 @@ export const Cell = (props) => {
278270
};
279271

280272
const onBlur = (event) => {
281-
selfClick.current = false;
282-
283273
if (props.editMode !== 'row' && editingState && getColumnProp('cellEditValidatorEvent') === 'blur') {
284274
switchCellToViewMode(event, true);
285275
}
@@ -364,13 +354,6 @@ export const Cell = (props) => {
364354
// eslint-disable-next-line react-hooks/exhaustive-deps
365355
}, [editingState]);
366356

367-
useUnmountEffect(() => {
368-
if (overlayEventListener.current) {
369-
OverlayService.off('overlay-click', overlayEventListener.current);
370-
overlayEventListener.current = null;
371-
}
372-
});
373-
374357
const createLoading = () => {
375358
const options = props.getVirtualScrollerOption('getLoaderOptions')(props.rowIndex, {
376359
cellIndex: props.index,

components/lib/datatable/BodyRow.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { ColumnBase } from '../column/ColumnBase';
33
import { useMergeProps } from '../hooks/Hooks';
44
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
55
import { BodyCell, RadioCheckCell } from './BodyCell';
6-
import { OverlayService } from '../overlayservice/OverlayService';
76
import { Fragment } from 'react';
87

98
export const BodyRow = React.memo((props) => {
@@ -534,10 +533,8 @@ export const BodyRow = React.memo((props) => {
534533
}
535534
}, []);
536535

537-
const onCellClick = (event, params, isEditable, editingState, setEditingState, selfClick, column, bindDocumentClickListener, overlayEventListener, isOutsideClicked) => {
536+
const onCellClick = (event, params, isEditable, editingState, setEditingState, column, bindDocumentClickListener) => {
538537
if (props.editMode !== 'row' && isEditable && !editingState && (props.selectOnEdit || (!props.selectOnEdit && props.isRowSelected))) {
539-
selfClick.current = true;
540-
541538
const onBeforeCellEditShow = getColumnProp(column, 'onBeforeCellEditShow');
542539
const onCellEditInit = getColumnProp(column, 'onCellEditInit');
543540
const cellEditValidatorEvent = getColumnProp(column, 'cellEditValidatorEvent');
@@ -571,14 +568,6 @@ export const BodyRow = React.memo((props) => {
571568

572569
if (cellEditValidatorEvent === 'click') {
573570
bindDocumentClickListener();
574-
575-
overlayEventListener.current = (e) => {
576-
if (!isOutsideClicked(e.target)) {
577-
selfClick.current = true;
578-
}
579-
};
580-
581-
OverlayService.on('overlay-click', overlayEventListener.current);
582571
}
583572
}, 1);
584573
}

0 commit comments

Comments
 (0)