@@ -8,7 +8,6 @@ import { ChevronDownIcon } from '../icons/chevrondown';
88import { ChevronRightIcon } from '../icons/chevronright' ;
99import { PencilIcon } from '../icons/pencil' ;
1010import { TimesIcon } from '../icons/times' ;
11- import { OverlayService } from '../overlayservice/OverlayService' ;
1211import { Ripple } from '../ripple/Ripple' ;
1312import { DomHandler , IconUtils , ObjectUtils , classNames } from '../utils/Utils' ;
1413import { RowCheckbox } from './RowCheckbox' ;
@@ -21,13 +20,10 @@ 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 ) ;
2926 const { ptm, ptmo, cx } = props . ptCallbacks ;
30-
3127 const getColumnProp = ( name ) => ColumnBase . getCProp ( props . column , name ) ;
3228
3329 const getColumnPTOptions = ( key ) => {
@@ -58,18 +54,18 @@ export const Cell = (props) => {
5854 return getColumnProp ( 'cellEditValidateOnClose' ) ;
5955 } ;
6056
57+ const isIgnoredElement = ( element ) => {
58+ const isOverlay = ( el ) => el . getAttribute && el . getAttribute ( 'data-pr-is-overlay' ) ;
59+
60+ return isOverlay ( element ) || DomHandler . getParents ( element ) . find ( ( el ) => isOverlay ( el ) ) ;
61+ } ;
62+
6163 const [ bindDocumentClickListener , unbindDocumentClickListener ] = useEventListener ( {
6264 type : 'click' ,
6365 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 ) ;
71-
72- selfClick . current = false ;
66+ if ( ! isIgnoredElement ( e . target ) && isOutsideClicked ( e . target ) ) {
67+ switchCellToViewMode ( e , true ) ;
68+ }
7369 } ,
7470 options : true ,
7571 when : isEditable ( )
@@ -120,9 +116,6 @@ export const Cell = (props) => {
120116 setTimeout ( ( ) => {
121117 setEditingState ( false ) ;
122118 unbindDocumentClickListener ( ) ;
123- OverlayService . off ( 'overlay-click' , overlayEventListener . current ) ;
124- overlayEventListener . current = null ;
125- selfClick . current = false ;
126119 } , 1 ) ;
127120 } ;
128121
@@ -175,7 +168,7 @@ export const Cell = (props) => {
175168 } ;
176169
177170 const onClick = ( event ) => {
178- props . onClick ( event , getCellCallbackParams ( event ) , isEditable ( ) , editingState , setEditingState , selfClick , props . column , bindDocumentClickListener , overlayEventListener , isOutsideClicked ) ;
171+ props . onClick ( event , getCellCallbackParams ( event ) , isEditable ( ) , editingState , setEditingState , props . column , bindDocumentClickListener ) ;
179172 } ;
180173
181174 const onMouseDown = ( event ) => {
@@ -276,8 +269,6 @@ export const Cell = (props) => {
276269 } ;
277270
278271 const onBlur = ( event ) => {
279- selfClick . current = false ;
280-
281272 if ( props . editMode !== 'row' && editingState && getColumnProp ( 'cellEditValidatorEvent' ) === 'blur' ) {
282273 switchCellToViewMode ( event , true ) ;
283274 }
@@ -363,11 +354,6 @@ export const Cell = (props) => {
363354 } , [ editingState ] ) ;
364355
365356 useUnmountEffect ( ( ) => {
366- if ( overlayEventListener . current ) {
367- OverlayService . off ( 'overlay-click' , overlayEventListener . current ) ;
368- overlayEventListener . current = null ;
369- }
370-
371357 if ( editingRowDataStateRef . current ) {
372358 editingRowDataStateRef . current = null ;
373359 }
0 commit comments