Skip to content

Commit b9d204c

Browse files
committed
fix(modal): visibleChange emited twice
1 parent e7a7eb9 commit b9d204c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { ModalContentComponent } from '../modal-content/modal-content.component'
4747
export class ModalComponent implements OnInit, OnDestroy {
4848

4949
static ngAcceptInputType_scrollable: BooleanInput;
50+
static ngAcceptInputType_visible: BooleanInput;
5051

5152
constructor(
5253
@Inject(DOCUMENT) private document: any,
@@ -120,11 +121,14 @@ export class ModalComponent implements OnInit, OnDestroy {
120121
* @type boolean
121122
*/
122123
@Input()
123-
set visible(visible: boolean) {
124-
this._visible = visible;
125-
this.setBackdrop(this.backdrop !== false && visible);
126-
this.setBodyStyles(visible);
127-
this.visibleChange.emit(visible);
124+
set visible(value: boolean) {
125+
const newValue = coerceBooleanProperty(value);
126+
if(this._visible !== newValue) {
127+
this._visible = newValue;
128+
this.setBackdrop(this.backdrop !== false && newValue);
129+
this.setBodyStyles(newValue);
130+
this.visibleChange.emit(newValue);
131+
}
128132
}
129133
get visible(): boolean {
130134
return this._visible;

0 commit comments

Comments
 (0)