From 836d87f49247ec763de0f2b614b69f5696e3fff4 Mon Sep 17 00:00:00 2001 From: aj-rosado <109146700+aj-rosado@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:59:13 +0000 Subject: [PATCH] [PS-1017] corrected web vault accessibility when deleting an item with keyboard (#3893) * PS-1017 Sending parent property to swal when delete popup appears above a modal * PS-1017 - Added more cases where the parent is necessary to swal react properly to keyboard inputs. Changed the way the ".modal-content" class is added to target to have it only on one place. * [PS-1017] Removed edit of target css selector from platform. Added full target on related component --- apps/web/src/app/core/web-platform-utils.service.ts | 4 +++- .../organizations/manage/collection-add-edit.component.ts | 4 +++- .../app/organizations/manage/group-add-edit.component.ts | 4 +++- .../app/organizations/manage/user-add-edit.component.ts | 8 ++++++-- .../web/src/app/organizations/vault/add-edit.component.ts | 1 + apps/web/src/app/send/add-edit.component.ts | 2 ++ apps/web/src/app/settings/emergency-add-edit.component.ts | 1 + apps/web/src/app/vault/add-edit.component.ts | 1 + apps/web/src/app/vault/attachments.component.ts | 1 + apps/web/src/app/vault/folder-add-edit.component.ts | 1 + libs/angular/src/components/add-edit.component.ts | 5 ++++- libs/angular/src/components/attachments.component.ts | 5 ++++- libs/angular/src/components/folder-add-edit.component.ts | 5 ++++- libs/angular/src/components/send/add-edit.component.ts | 5 ++++- libs/common/src/abstractions/platformUtils.service.ts | 3 ++- 15 files changed, 40 insertions(+), 10 deletions(-) diff --git a/apps/web/src/app/core/web-platform-utils.service.ts b/apps/web/src/app/core/web-platform-utils.service.ts index bb8bf7707e..2d682a35aa 100644 --- a/apps/web/src/app/core/web-platform-utils.service.ts +++ b/apps/web/src/app/core/web-platform-utils.service.ts @@ -140,7 +140,8 @@ export class WebPlatformUtilsService implements PlatformUtilsService { confirmText?: string, cancelText?: string, type?: string, - bodyIsHtml = false + bodyIsHtml = false, + target?: string ) { let iconClasses: string = null; if (type != null) { @@ -182,6 +183,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService { cancelButtonText: cancelText, showConfirmButton: true, confirmButtonText: confirmText == null ? this.i18nService.t("ok") : confirmText, + target: target != null ? target : "body", }); if (bootstrapModal != null) { diff --git a/apps/web/src/app/organizations/manage/collection-add-edit.component.ts b/apps/web/src/app/organizations/manage/collection-add-edit.component.ts index bf38103140..1a26d21fba 100644 --- a/apps/web/src/app/organizations/manage/collection-add-edit.component.ts +++ b/apps/web/src/app/organizations/manage/collection-add-edit.component.ts @@ -158,7 +158,9 @@ export class CollectionAddEditComponent implements OnInit { this.name, this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + "app-collection-add-edit .modal-content" ); if (!confirmed) { return false; diff --git a/apps/web/src/app/organizations/manage/group-add-edit.component.ts b/apps/web/src/app/organizations/manage/group-add-edit.component.ts index f916e20aee..39c96c759f 100644 --- a/apps/web/src/app/organizations/manage/group-add-edit.component.ts +++ b/apps/web/src/app/organizations/manage/group-add-edit.component.ts @@ -130,7 +130,9 @@ export class GroupAddEditComponent implements OnInit { this.name, this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + "app-group-add-edit .modal-content" ); if (!confirmed) { return false; diff --git a/apps/web/src/app/organizations/manage/user-add-edit.component.ts b/apps/web/src/app/organizations/manage/user-add-edit.component.ts index cb59311223..52506568d9 100644 --- a/apps/web/src/app/organizations/manage/user-add-edit.component.ts +++ b/apps/web/src/app/organizations/manage/user-add-edit.component.ts @@ -215,7 +215,9 @@ export class UserAddEditComponent implements OnInit { this.i18nService.t("removeUserIdAccess", this.name), this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + "app-user-add-edit .modal-content" ); if (!confirmed) { return false; @@ -248,7 +250,9 @@ export class UserAddEditComponent implements OnInit { this.i18nService.t("revokeUserId", this.name), this.i18nService.t("revokeAccess"), this.i18nService.t("cancel"), - "warning" + "warning", + false, + "app-user-add-edit .modal-content" ); if (!confirmed) { return false; diff --git a/apps/web/src/app/organizations/vault/add-edit.component.ts b/apps/web/src/app/organizations/vault/add-edit.component.ts index dbbbf42dd0..6a03696c2e 100644 --- a/apps/web/src/app/organizations/vault/add-edit.component.ts +++ b/apps/web/src/app/organizations/vault/add-edit.component.ts @@ -29,6 +29,7 @@ import { AddEditComponent as BaseAddEditComponent } from "../../vault/add-edit.c }) export class AddEditComponent extends BaseAddEditComponent { originalCipher: Cipher = null; + protected override componentName = "app-org-vault-add-edit"; constructor( cipherService: CipherService, diff --git a/apps/web/src/app/send/add-edit.component.ts b/apps/web/src/app/send/add-edit.component.ts index 9091a60dd8..d8f8aa491f 100644 --- a/apps/web/src/app/send/add-edit.component.ts +++ b/apps/web/src/app/send/add-edit.component.ts @@ -16,6 +16,8 @@ import { StateService } from "@bitwarden/common/abstractions/state.service"; templateUrl: "add-edit.component.html", }) export class AddEditComponent extends BaseAddEditComponent { + override componentName = "app-send-add-edit"; + constructor( i18nService: I18nService, platformUtilsService: PlatformUtilsService, diff --git a/apps/web/src/app/settings/emergency-add-edit.component.ts b/apps/web/src/app/settings/emergency-add-edit.component.ts index c709f4a929..3e97067d6f 100644 --- a/apps/web/src/app/settings/emergency-add-edit.component.ts +++ b/apps/web/src/app/settings/emergency-add-edit.component.ts @@ -26,6 +26,7 @@ import { AddEditComponent as BaseAddEditComponent } from "../vault/add-edit.comp export class EmergencyAddEditComponent extends BaseAddEditComponent { originalCipher: Cipher = null; viewOnly = true; + protected override componentName = "app-org-vault-add-edit"; constructor( cipherService: CipherService, diff --git a/apps/web/src/app/vault/add-edit.component.ts b/apps/web/src/app/vault/add-edit.component.ts index 1847be254e..a8372871f9 100644 --- a/apps/web/src/app/vault/add-edit.component.ts +++ b/apps/web/src/app/vault/add-edit.component.ts @@ -37,6 +37,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On viewOnly = false; protected totpInterval: number; + protected override componentName = "app-vault-add-edit"; constructor( cipherService: CipherService, diff --git a/apps/web/src/app/vault/attachments.component.ts b/apps/web/src/app/vault/attachments.component.ts index a2f361dd01..63e1f8bf39 100644 --- a/apps/web/src/app/vault/attachments.component.ts +++ b/apps/web/src/app/vault/attachments.component.ts @@ -17,6 +17,7 @@ import { AttachmentView } from "@bitwarden/common/models/view/attachment.view"; }) export class AttachmentsComponent extends BaseAttachmentsComponent { viewOnly = false; + protected override componentName = "app-vault-attachments"; constructor( cipherService: CipherService, diff --git a/apps/web/src/app/vault/folder-add-edit.component.ts b/apps/web/src/app/vault/folder-add-edit.component.ts index a014389577..9c1910b32c 100644 --- a/apps/web/src/app/vault/folder-add-edit.component.ts +++ b/apps/web/src/app/vault/folder-add-edit.component.ts @@ -12,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti templateUrl: "folder-add-edit.component.html", }) export class FolderAddEditComponent extends BaseFolderAddEditComponent { + protected override componentName = "app-folder-add-edit"; constructor( folderService: FolderService, folderApiService: FolderApiServiceAbstraction, diff --git a/libs/angular/src/components/add-edit.component.ts b/libs/angular/src/components/add-edit.component.ts index 2d59ac475f..c7b73bbcce 100644 --- a/libs/angular/src/components/add-edit.component.ts +++ b/libs/angular/src/components/add-edit.component.ts @@ -77,6 +77,7 @@ export class AddEditComponent implements OnInit, OnDestroy { canUseReprompt = true; organization: Organization; + protected componentName = ""; protected destroy$ = new Subject(); protected writeableCollections: CollectionView[]; private personalOwnershipPolicyAppliesToActiveUser: boolean; @@ -397,7 +398,9 @@ export class AddEditComponent implements OnInit, OnDestroy { this.i18nService.t("deleteItem"), this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + this.componentName != "" ? this.componentName + " .modal-content" : null ); if (!confirmed) { return false; diff --git a/libs/angular/src/components/attachments.component.ts b/libs/angular/src/components/attachments.component.ts index a484661be3..8a8db67618 100644 --- a/libs/angular/src/components/attachments.component.ts +++ b/libs/angular/src/components/attachments.component.ts @@ -29,6 +29,7 @@ export class AttachmentsComponent implements OnInit { deletePromises: { [id: string]: Promise } = {}; reuploadPromises: { [id: string]: Promise } = {}; emergencyAccessId?: string = null; + protected componentName = ""; constructor( protected cipherService: CipherService, @@ -104,7 +105,9 @@ export class AttachmentsComponent implements OnInit { this.i18nService.t("deleteAttachment"), this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + this.componentName != "" ? this.componentName + " .modal-content" : null ); if (!confirmed) { return; diff --git a/libs/angular/src/components/folder-add-edit.component.ts b/libs/angular/src/components/folder-add-edit.component.ts index c389d72dcd..02b8922b50 100644 --- a/libs/angular/src/components/folder-add-edit.component.ts +++ b/libs/angular/src/components/folder-add-edit.component.ts @@ -18,6 +18,7 @@ export class FolderAddEditComponent implements OnInit { title: string; formPromise: Promise; deletePromise: Promise; + protected componentName = ""; constructor( protected folderService: FolderService, @@ -65,7 +66,9 @@ export class FolderAddEditComponent implements OnInit { this.i18nService.t("deleteFolder"), this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + this.componentName != "" ? this.componentName + " .modal-content" : null ); if (!confirmed) { return false; diff --git a/libs/angular/src/components/send/add-edit.component.ts b/libs/angular/src/components/send/add-edit.component.ts index dfa03e1942..51c8f12048 100644 --- a/libs/angular/src/components/send/add-edit.component.ts +++ b/libs/angular/src/components/send/add-edit.component.ts @@ -45,6 +45,7 @@ export class AddEditComponent implements OnInit, OnDestroy { alertShown = false; showOptions = false; + protected componentName = ""; private sendLinkBaseUrl: string; private destroy$ = new Subject(); @@ -242,7 +243,9 @@ export class AddEditComponent implements OnInit, OnDestroy { this.i18nService.t("deleteSend"), this.i18nService.t("yes"), this.i18nService.t("no"), - "warning" + "warning", + false, + this.componentName != "" ? this.componentName + " .modal-content" : null ); if (!confirmed) { return false; diff --git a/libs/common/src/abstractions/platformUtils.service.ts b/libs/common/src/abstractions/platformUtils.service.ts index 8f2f546127..296b8a2404 100644 --- a/libs/common/src/abstractions/platformUtils.service.ts +++ b/libs/common/src/abstractions/platformUtils.service.ts @@ -34,7 +34,8 @@ export abstract class PlatformUtilsService { confirmText?: string, cancelText?: string, type?: string, - bodyIsHtml?: boolean + bodyIsHtml?: boolean, + target?: string ) => Promise; isDev: () => boolean; isSelfHost: () => boolean;