Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[web] Autofocus on the delete button on the confirmation dialog

Manav Rathi3352e2a07521
diff --git a/web/apps/photos/src/utils/ui/index.tsx b/web/apps/photos/src/utils/ui/index.tsx
index 0c33bc7dbe..9176055831 100644
--- a/web/apps/photos/src/utils/ui/index.tsx
+++ b/web/apps/photos/src/utils/ui/index.tsx
@@ -47,6 +47,7 @@ export const getTrashFileMessage = (deleteFileHelper): DialogBoxAttributes => ({
action: deleteFileHelper,
text: t("MOVE_TO_TRASH"),
variant: "critical",
+ autoFocus: true,
},
close: { text: t("cancel") },
});
diff --git a/web/packages/shared/components/DialogBox/index.tsx b/web/packages/shared/components/DialogBox/index.tsx
index abe5c09cd1..e6b9ef55db 100644
--- a/web/packages/shared/components/DialogBox/index.tsx
+++ b/web/packages/shared/components/DialogBox/index.tsx
@@ -94,6 +94,8 @@ export default function DialogBox({
onClose();
}}
disabled={attributes.proceed.disabled}
+ autoFocus={attributes.proceed?.autoFocus}
+ disableFocusRipple={attributes.proceed?.autoFocus}
>
{attributes.proceed.text}
</Button>
diff --git a/web/packages/shared/components/DialogBox/types.ts b/web/packages/shared/components/DialogBox/types.ts
index 944cd79017..079017b4bd 100644
--- a/web/packages/shared/components/DialogBox/types.ts
+++ b/web/packages/shared/components/DialogBox/types.ts
@@ -20,6 +20,12 @@ export interface DialogBoxAttributes {
action: () => void;
variant?: ButtonProps["color"];
disabled?: boolean;
+ /**
+ * If `true`, then the button representing the proceed action is focused
+ * when the dialog is opened. This allows the user to directly press
+ * ENTER to complete that action.
+ */
+ autoFocus?: boolean;
};
secondary?: {
text: string;