]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/confirm/confirm.component.ts
Use form-control to display box-shadow on form inputs/selects upon focus
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / confirm / confirm.component.ts
index 53aed14d7bf649b7823875a3ecb37b28594bb19f..c6e40fe72a8c20ce173a34eb588669669a9be700 100644 (file)
@@ -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)
+          }
+        })
   }
 }