Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited8859a

Browse files
committed
fix(dropdown): autoClose inside click fails for dynamic content
1 parentb511885 commited8859a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

‎projects/coreui-angular/src/lib/dropdown/dropdown/dropdown.component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
235235
returnthis.variant==='input-group' ?{display:'contents'} :{};
236236
}
237237

238+
privateclickedTarget!:HTMLElement;
239+
240+
@HostListener('click',['$event'])
241+
privateonHostClick($event:MouseEvent):void{
242+
this.clickedTarget=$event.targetasHTMLElement;
243+
}
244+
238245
dropdownStateSubscribe(subscribe:boolean=true):void{
239246
if(subscribe){
240247
this.dropdownStateSubscription=
@@ -313,28 +320,24 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
313320
}
314321

315322
privatesetListeners():void{
316-
consthost=this.elementRef.nativeElement;
317323
this.listeners.push(
318324
this.renderer.listen(this.document,'click',(event)=>{
325+
consttarget=event.targetasHTMLElement;
319326
if(this._toggler?.elementRef.nativeElement.contains(event.target)){
320327
return;
321328
}
322329
if(this.autoClose===true){
323330
this.setVisibleState(false);
324331
return;
325332
}
326-
if(!host.contains(event.target)){
327-
if(this.autoClose==='outside'){
333+
if(this.clickedTarget===target&&this.autoClose==='inside'){
328334
this.setVisibleState(false);
329335
return;
330336
}
331-
}
332-
if(this._menu.elementRef.nativeElement.contains(event.target)){
333-
if(this.autoClose==='inside'){
337+
if(this.clickedTarget!==target&&this.autoClose==='outside'){
334338
this.setVisibleState(false);
335339
return;
336340
}
337-
}
338341
})
339342
);
340343
this.listeners.push(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp