I have the canDeactivate function, and when the data is not saved, I call the modal window,
public canDeactivate(nextState?: RouterStateSnapshot): boolean {
if (this.formChangeUnsaved) {
this.bsModalRef = this.modalService.show(ModalConfirmFormUnsavedComponent, {
backdrop: true,
ignoreBackdropClick: true,
keyboard: true,
});
this.bsModalRef.content.confirm.subscribe((isSaved) => {
if (isSaved) {
this.clientApi.autoSaveFormNextStateUrl.next(nextState.url);
this.bsModalRef.hide();
} else {
this.bsModalRef.hide();
this.formChangeUnsaved = false;
void this.router.navigateByUrl(nextState.url);
}
});
return false;
}
return true;
}` }
and after switching to another url I have a modal window called and at the first call everything is fine, I switch back to the component and switch to another url again to call the modal window again then my backdropRef is undefined, this appeared after the update to 11.0.2