Skip to content

Commit fe57b96

Browse files
committed
fix(modal): c-modal/backdrop click isolation
1 parent ab21f45 commit fe57b96

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

projects/coreui-angular/src/lib/modal/modal/modal.component.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,22 @@ export class ModalComponent implements OnInit, OnDestroy {
237237

238238
@HostListener('click', ['$event'])
239239
public onClickHandler($event: MouseEvent): void {
240-
$event.stopPropagation();
240+
241241
if (this.mouseDownTarget !== $event.target) {
242242
this.mouseDownTarget = null;
243243
return;
244244
}
245-
if (this.backdrop === 'static') {
246-
this.setStaticBackdrop();
247-
return;
245+
246+
const targetElement = $event.target;
247+
if (targetElement === this.hostElement.nativeElement) {
248+
249+
if (this.backdrop === 'static') {
250+
this.setStaticBackdrop();
251+
return;
252+
}
253+
254+
this.modalService.toggle({ show: false, modal: this });
248255
}
249-
this.modalService.toggle({ show: false, modal: this });
250256
}
251257

252258
ngOnInit(): void {

0 commit comments

Comments
 (0)