@@ -353,24 +353,32 @@ class Overlay<
353353 this . _initPositionController ( ) ;
354354 }
355355
356- _documentDownHandler ( e ) : boolean | undefined {
356+ _documentDownHandler ( e ) : boolean {
357357 if ( this . _showAnimationProcessing ) {
358358 this . _stopAnimation ( ) ;
359359 }
360- const isAttachedTarget = $ ( window . document ) . is ( e . target )
361- || domUtils . contains ( window . document , e . target ) ;
362- const isInnerOverlay = $ ( e . target ) . closest ( `.${ INNER_OVERLAY_CLASS } ` ) . length ;
363- const outsideClick = isAttachedTarget && ! isInnerOverlay && ! ( this . _$content ?. is ( e . target )
360+
361+ const { target } = e ;
362+ const $target = $ ( target ) ;
363+
364+ const isTargetDocument = domUtils . contains ( window . document , target ) ;
365+ const isAttachedTarget = $ ( window . document ) . is ( $target ) || isTargetDocument ;
366+ const isInnerOverlay = $ ( $target ) . closest ( `.${ INNER_OVERLAY_CLASS } ` ) . length ;
367+ const isTargetContent = this . _$content ?. is ( $target ) ;
368+ const isTargetInContent = domUtils . contains ( this . _$content ?. get ( 0 ) , target ) ;
369+
370+ const isOutsideClick = isAttachedTarget
371+ && ! isInnerOverlay
364372 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
365- || domUtils . contains ( this . _$content ?. get ( 0 ) , e . target ) ) ;
373+ && ! ( isTargetContent || isTargetInContent ) ;
366374
367- if ( outsideClick && this . _shouldHideOnOutsideClick ( e ) ) {
375+ if ( isOutsideClick && this . _shouldHideOnOutsideClick ( e ) ) {
368376 this . _outsideClickHandler ( e ) ;
369377 }
370378
371379 const { propagateOutsideClick } = this . option ( ) ;
372380
373- return propagateOutsideClick ;
381+ return Boolean ( propagateOutsideClick ) ;
374382 }
375383
376384 _shouldHideOnOutsideClick ( e ) : boolean | undefined {
0 commit comments