@@ -260,12 +260,13 @@ export class MultipleSelectInstance {
260
260
document . body ,
261
261
'click' ,
262
262
( ( e : MouseEvent & { target : HTMLElement } ) => {
263
- if ( e . target === this . choiceElm || findParent ( e . target , '.ms-choice' ) === this . choiceElm ) {
263
+ if ( this . getEventTarget ( e ) === this . choiceElm || findParent ( this . getEventTarget ( e ) , '.ms-choice' ) === this . choiceElm ) {
264
264
return ;
265
265
}
266
266
267
267
if (
268
- ( e . target === this . dropElm || ( findParent ( e . target , '.ms-drop' ) !== this . dropElm && e . target !== this . elm ) ) &&
268
+ ( this . getEventTarget ( e ) === this . dropElm ||
269
+ ( findParent ( this . getEventTarget ( e ) , '.ms-drop' ) !== this . dropElm && this . getEventTarget ( e ) !== this . elm ) ) &&
269
270
this . options . isOpen
270
271
) {
271
272
this . close ( 'body.click' ) ;
@@ -531,6 +532,13 @@ export class MultipleSelectInstance {
531
532
return rows ;
532
533
}
533
534
535
+ protected getEventTarget ( e : Event & { target : HTMLElement } ) : HTMLElement {
536
+ if ( e . composedPath ) {
537
+ return e . composedPath ( ) [ 0 ] as HTMLElement ;
538
+ }
539
+ return e . target as HTMLElement ;
540
+ }
541
+
534
542
protected getListRows ( ) : HtmlStruct [ ] {
535
543
const rows : HtmlStruct [ ] = [ ] ;
536
544
this . updateData = [ ] ;
@@ -799,15 +807,15 @@ export class MultipleSelectInstance {
799
807
800
808
const toggleOpen = ( e : MouseEvent & { target : HTMLElement } ) => {
801
809
e . preventDefault ( ) ;
802
- if ( e . target . classList . contains ( 'ms-icon-close' ) ) {
810
+ if ( this . getEventTarget ( e ) . classList . contains ( 'ms-icon-close' ) ) {
803
811
return ;
804
812
}
805
813
this . options . isOpen ? this . close ( 'toggle.close' ) : this . open ( ) ;
806
814
} ;
807
815
808
816
if ( this . labelElm ) {
809
817
this . _bindEventService . bind ( this . labelElm , 'click' , ( ( e : MouseEvent & { target : HTMLElement } ) => {
810
- if ( e . target . nodeName . toLowerCase ( ) !== 'label' ) {
818
+ if ( this . getEventTarget ( e ) . nodeName . toLowerCase ( ) !== 'label' ) {
811
819
return ;
812
820
}
813
821
toggleOpen ( e ) ;
@@ -1008,7 +1016,7 @@ export class MultipleSelectInstance {
1008
1016
this . dropElm ,
1009
1017
'mouseover' ,
1010
1018
( ( e : MouseEvent & { target : HTMLDivElement | HTMLLIElement } ) => {
1011
- const liElm = ( e . target . closest ( '.ms-select-all' ) || e . target . closest ( 'li' ) ) as HTMLLIElement ;
1019
+ const liElm = ( this . getEventTarget ( e ) . closest ( '.ms-select-all' ) || this . getEventTarget ( e ) . closest ( 'li' ) ) as HTMLLIElement ;
1012
1020
1013
1021
if ( this . dropElm ?. contains ( liElm ) && this . lastMouseOverPosition !== `${ e . clientX } :${ e . clientY } ` ) {
1014
1022
const optionElms = this . dropElm ?. querySelectorAll < HTMLLIElement > ( OPTIONS_LIST_SELECTOR ) || [ ] ;
@@ -1048,7 +1056,7 @@ export class MultipleSelectInstance {
1048
1056
case ' ' : {
1049
1057
// if we're focused on the OK button then don't execute following block
1050
1058
if ( document . activeElement !== this . okButtonElm ) {
1051
- const liElm = e . target . closest ( '.ms-select-all' ) || e . target . closest ( 'li' ) ;
1059
+ const liElm = this . getEventTarget ( e ) . closest ( '.ms-select-all' ) || this . getEventTarget ( e ) . closest ( 'li' ) ;
1052
1060
if ( ( e . key === ' ' && this . options . filter ) || ( this . options . filterAcceptOnEnter && ! liElm ) ) {
1053
1061
return ;
1054
1062
}
@@ -1108,8 +1116,8 @@ export class MultipleSelectInstance {
1108
1116
protected infiniteScrollHandler ( e : ( MouseEvent & { target : HTMLElement } ) | null , idx ?: number , fullCount ?: number ) {
1109
1117
let needHighlightRecalc = false ;
1110
1118
1111
- if ( e ?. target && this . ulElm && this . scrolledByMouse ) {
1112
- const scrollPos = e . target . scrollTop + e . target . clientHeight ;
1119
+ if ( e && this . getEventTarget ( e ) && this . ulElm && this . scrolledByMouse ) {
1120
+ const scrollPos = this . getEventTarget ( e ) . scrollTop + this . getEventTarget ( e ) . clientHeight ;
1113
1121
if ( scrollPos === this . ulElm . scrollHeight ) {
1114
1122
needHighlightRecalc = true ;
1115
1123
}
0 commit comments