1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00

[PM-23562] Prevent closing dialog and window when uploading an attachment (#17287)

* Prevent users from cancelling an in-flight upload, and attempt to block them from closing the window.

* Add comment for deprecated event.returnValue
This commit is contained in:
Nik Gilmore
2025-12-01 12:50:13 -08:00
committed by GitHub
parent aac7ca172b
commit e694ab490c
3 changed files with 56 additions and 2 deletions

View File

@@ -108,11 +108,21 @@ export class CipherAttachmentsComponent implements OnInit, AfterViewInit {
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input() submitBtn?: ButtonComponent;
/** Emits when a file upload is started */
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@Output() onUploadStarted = new EventEmitter<void>();
/** Emits after a file has been successfully uploaded */
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@Output() onUploadSuccess = new EventEmitter<void>();
/** Emits when a file upload fails */
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@Output() onUploadFailed = new EventEmitter<void>();
/** Emits after a file has been successfully removed */
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@@ -196,6 +206,8 @@ export class CipherAttachmentsComponent implements OnInit, AfterViewInit {
/** Save the attachments to the cipher */
submit = async () => {
this.onUploadStarted.emit();
const file = this.attachmentForm.value.file;
if (file === null) {
this.toastService.showToast({
@@ -253,6 +265,7 @@ export class CipherAttachmentsComponent implements OnInit, AfterViewInit {
variant: "error",
message: errorMessage,
});
this.onUploadFailed.emit();
}
};