X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fconfirm%2Fconfirm.component.ts;h=c6e40fe72a8c20ce173a34eb588669669a9be700;hb=a6d5ff7604a3c2a94ff8814e2df7ca7bb2b48634;hp=53aed14d7bf649b7823875a3ecb37b28594bb19f;hpb=f36da21e40104a50acb00132920b835240cebb38;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/confirm/confirm.component.ts b/client/src/app/shared/confirm/confirm.component.ts index 53aed14d7..c6e40fe72 100644 --- a/client/src/app/shared/confirm/confirm.component.ts +++ b/client/src/app/shared/confirm/confirm.component.ts @@ -3,6 +3,7 @@ import { ConfirmService } from '@app/core/confirm/confirm.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' +import { POP_STATE_MODAL_DISMISS } from '@app/shared/misc/constants' @Component({ selector: 'my-confirm', @@ -44,7 +45,6 @@ export class ConfirmComponent implements OnInit { ) } - @HostListener('document:keydown.enter') confirm () { if (this.openedModal) this.openedModal.close() } @@ -59,10 +59,15 @@ export class ConfirmComponent implements OnInit { showModal () { this.inputValue = '' - this.openedModal = this.modalService.open(this.confirmModal) + this.openedModal = this.modalService.open(this.confirmModal, { centered: true }) this.openedModal.result .then(() => this.confirmService.confirmResponse.next(true)) - .catch(() => this.confirmService.confirmResponse.next(false)) + .catch((reason: string) => { + // If the reason was that the user used the back button, we don't care about the confirm dialog result + if (!reason || reason !== POP_STATE_MODAL_DISMISS) { + this.confirmService.confirmResponse.next(false) + } + }) } }