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

Commit eb6224f

Browse files
committed
Improve Overlay Handling (Minimal)
1 parent e341085 commit eb6224f

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

components/lib/calendar/CalendarPanel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export const CalendarPanel = React.forwardRef((props, ref) => {
1818
'aria-label': localeOption('chooseDate', props.locale),
1919
'aria-modal': props.inline ? null : 'true',
2020
onClick: props.onClick,
21-
onMouseUp: props.onMouseUp
21+
onMouseUp: props.onMouseUp,
22+
'data-pr-is-overlay': true
2223
},
2324
props.ptm('panel', { hostName: props.hostName })
2425
);

components/lib/datatable/BodyCell.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const Cell = (props) => {
2727
const initFocusTimeout = React.useRef(null);
2828
const editingRowDataStateRef = React.useRef(null);
2929
const { ptm, ptmo, cx } = props.ptCallbacks;
30-
3130
const getColumnProp = (name) => ColumnBase.getCProp(props.column, name);
3231

3332
const getColumnPTOptions = (key) => {
@@ -58,16 +57,18 @@ export const Cell = (props) => {
5857
return getColumnProp('cellEditValidateOnClose');
5958
};
6059

60+
const isIgnoredElement = (element) => {
61+
const isCellEditor = (el) => el.getAttribute && el.getAttribute('data-pr-is-overlay');
62+
63+
return isCellEditor(element) || DomHandler.getParents(element).find((el) => isCellEditor(el));
64+
};
65+
6166
const [bindDocumentClickListener, unbindDocumentClickListener] = useEventListener({
6267
type: 'click',
6368
listener: (e) => {
64-
setTimeout(() => {
65-
if (!selfClick.current && isOutsideClicked(e.target)) {
66-
// #2666 for overlay components and outside is clicked
67-
68-
switchCellToViewMode(e, true);
69-
}
70-
}, 0);
69+
if (!isIgnoredElement(e.target) && isOutsideClicked(e.target)) {
70+
switchCellToViewMode(e, true);
71+
}
7172

7273
selfClick.current = false;
7374
},

components/lib/dropdown/DropdownPanel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ export const DropdownPanel = React.memo(
308308
{
309309
className: classNames(props.panelClassName, cx('panel', { context })),
310310
style: sx('panel'),
311-
onClick: props.onClick
311+
onClick: props.onClick,
312+
'data-pr-is-overlay': true
312313
},
313314
getPTOptions('panel')
314315
);

0 commit comments

Comments
 (0)