Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix narrow person tiles and scope naming dialog accessibility

vijayadithyanpj8925f8cc54e9
diff --git a/web/apps/photos/src/components/Collections/AllPeople.tsx b/web/apps/photos/src/components/Collections/AllPeople.tsx
index 965228619a..58bdea246e 100644
--- a/web/apps/photos/src/components/Collections/AllPeople.tsx
+++ b/web/apps/photos/src/components/Collections/AllPeople.tsx
@@ -967,11 +967,14 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
}}
>
<Typography
+ title={t("new_person")}
sx={{
position: "absolute",
- top: 10,
- left: 10,
- right: 10,
+ top: 8,
+ insetInline: 8,
+ overflow: "hidden",
+ whiteSpace: "nowrap",
+ textOverflow: "ellipsis",
fontSize: 14,
lineHeight: "20px",
fontWeight: 500,
@@ -985,6 +988,7 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
+ fontSize: 20,
}}
/>
</CollectionTileButton>
@@ -1000,7 +1004,7 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
<SingleInputDialog
open={openNameInput}
- variant="v2"
+ variant="people"
sx={{ "& .MuiDialog-paper": { borderRadius: "32px" } }}
onClose={() => {
setOpenNameInput(false);
diff --git a/web/packages/base/components/SingleInputDialog.tsx b/web/packages/base/components/SingleInputDialog.tsx
index 606659c77f..7e64e0400f 100644
--- a/web/packages/base/components/SingleInputDialog.tsx
+++ b/web/packages/base/components/SingleInputDialog.tsx
@@ -38,19 +38,22 @@ export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
[onClose, onSubmit],
);
- if (variant === "v2") {
+ if (variant !== "default") {
return (
<Dialog
open={open}
onClose={onClose}
maxWidth={false}
- aria-labelledby={titleID}
+ aria-labelledby={variant === "people" ? titleID : undefined}
sx={sx}
slotProps={{ paper: { sx: v2PaperSx } }}
>
<Stack sx={{ p: "20px", gap: "20px" }}>
<Stack direction="row" sx={v2HeaderRowSx}>
- <Typography id={titleID} sx={v2TitleSx}>
+ <Typography
+ id={variant === "people" ? titleID : undefined}
+ sx={v2TitleSx}
+ >
{title}
</Typography>
<IconButton
@@ -63,7 +66,7 @@ export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
</Stack>
<SingleInputForm
key={open ? "open" : "closed"}
- variant="v2"
+ variant={variant}
onCancel={onClose}
onSubmit={handleSubmit}
{...rest}
diff --git a/web/packages/base/components/SingleInputForm.tsx b/web/packages/base/components/SingleInputForm.tsx
index 6c9ba22300..f8d752e40d 100644
--- a/web/packages/base/components/SingleInputForm.tsx
+++ b/web/packages/base/components/SingleInputForm.tsx
@@ -22,7 +22,7 @@ export type SingleInputFormProps = Pick<
TextFieldProps,
"label" | "placeholder" | "autoComplete" | "autoFocus" | "slotProps"
> & {
- variant?: "default" | "v2";
+ variant?: "default" | "v2" | "people";
inputType?: TextFieldProps["type"];
initialValue?: string;
submitButtonColor?: ButtonProps["color"];
@@ -59,7 +59,7 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
const formik = useFormik({
initialValues: { value: initialValue ?? "" },
- enableReinitialize: variant === "v2",
+ enableReinitialize: variant !== "default",
onSubmit: async (values, { setFieldError }) => {
const value = values.value;
const setValueFieldError = (message: string) =>
@@ -78,7 +78,7 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
},
});
- if (variant === "v2") {
+ if (variant !== "default") {
const error = formik.errors.value;
return (
<Stack
@@ -89,16 +89,18 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
<Stack sx={{ gap: "8px" }}>
{rest.label && (
<Typography
- component="label"
- htmlFor={inputID}
+ component={variant === "people" ? "label" : "p"}
+ htmlFor={variant === "people" ? inputID : undefined}
sx={v2LabelSx}
>
{rest.label}
</Typography>
)}
<InputBase
- id={inputID}
- aria-describedby={error ? helperID : undefined}
+ id={variant === "people" ? inputID : undefined}
+ aria-describedby={
+ variant === "people" && error ? helperID : undefined
+ }
name="value"
value={formik.values.value}
onChange={formik.handleChange}
@@ -111,8 +113,8 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
sx={v2InputSx}
/>
<Typography
- id={helperID}
- aria-live="polite"
+ id={variant === "people" ? helperID : undefined}
+ aria-live={variant === "people" ? "polite" : undefined}
sx={v2HelperSx(!!error)}
>
{error ?? ""}
@@ -123,7 +125,10 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
<ButtonBase
onClick={onCancel}
disabled={formik.isSubmitting}
- sx={v2CancelButtonSx}
+ sx={[
+ v2CancelButtonSx,
+ variant === "people" && peopleActionFocusSx,
+ ]}
>
{t("cancel")}
</ButtonBase>
@@ -131,7 +136,10 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
<ButtonBase
type="submit"
disabled={formik.isSubmitting}
- sx={v2SubmitButtonSx}
+ sx={[
+ v2SubmitButtonSx,
+ variant === "people" && peopleActionFocusSx,
+ ]}
>
{formik.isSubmitting ? (
<CircularProgress
@@ -255,11 +263,6 @@ const v2BaseActionSx = {
lineHeight: "20px",
fontWeight: 500,
fontFamily: "inherit",
- "&.Mui-focusVisible": {
- outline: "1px solid",
- outlineColor: "stroke.base",
- outlineOffset: "2px",
- },
"&.Mui-disabled": { opacity: 0.7 },
};
const v2CancelButtonSx = (theme: Theme) => ({
@@ -283,3 +286,11 @@ const v2SubmitButtonSx = {
opacity: 0.7,
},
};
+
+const peopleActionFocusSx = {
+ "&.Mui-focusVisible": {
+ outline: "1px solid",
+ outlineColor: "stroke.base",
+ outlineOffset: "2px",
+ },
+};