File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ export class SuiDropdown implements AfterContentInit {
3737 return this . service . isOpen && ! this . service . isNested ;
3838 }
3939
40+ // Tracks dropdown open state between `mousedown` and `click`.
41+ private _isOpenOnMouseDown :boolean ;
42+
4043 @Input ( )
4144 public get isOpen ( ) :boolean {
4245 return this . service . isOpen ;
@@ -115,9 +118,14 @@ export class SuiDropdown implements AfterContentInit {
115118 }
116119 }
117120
121+ @HostListener ( "document:mousedown" , [ "$event" ] )
122+ public onDocumentMouseDown ( e :MouseEvent ) :void {
123+ this . _isOpenOnMouseDown = this . isOpen ;
124+ }
125+
118126 @HostListener ( "document:click" , [ "$event" ] )
119127 public onDocumentClick ( e :MouseEvent ) :void {
120- if ( ! this . _element . nativeElement . contains ( e . target ) ) {
128+ if ( ! this . _element . nativeElement . contains ( e . target ) && this . _isOpenOnMouseDown ) {
121129 if ( this . service . autoCloseMode === DropdownAutoCloseType . ItemClick ||
122130 this . service . autoCloseMode === DropdownAutoCloseType . OutsideClick ) {
123131 // No need to reflect in parent since they are also bound to document.
You can’t perform that action at this time.
0 commit comments