💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web] Keep action prompts visible and announce captions
AswinAsokd2cbb354700d
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsxindex 4caa47ee35..66a8fbc4db 100644--- a/web/apps/photos/src/pages/_app.tsx+++ b/web/apps/photos/src/pages/_app.tsx@@ -179,7 +179,12 @@ const App: React.FC<PhotosAppProps> = ({ Component, pageProps }) => {<ThemedLoadingBar ref={loadingBarRef} /><AttributedMiniDialog {...miniDialogProps} appearance="centered" />- <Notification {...notificationProps} />+ <Notification+ {...notificationProps}+ autoHideDuration={+ notificationProps.attributes?.onClick ? null : undefined+ }+ />{isDesktop && (<WindowTitlebar {...{ isFileViewerOpen }}>diff --git a/web/apps/photos/tests/notification-icons.test.tsx b/web/apps/photos/tests/notification-icons.test.tsxindex 5dc7e45f19..0e9d78eef8 100644--- a/web/apps/photos/tests/notification-icons.test.tsx+++ b/web/apps/photos/tests/notification-icons.test.tsx@@ -5,8 +5,16 @@ import {type NotificationAttributes,} from "ente-base/components/Notification";import { photosTheme } from "ente-base/components/utils/theme";+import i18next from "i18next";import { renderToStaticMarkup } from "react-dom/server";-import { describe, expect, test, vi } from "vitest";+import { beforeAll, describe, expect, test, vi } from "vitest";++beforeAll(async () => {+ await i18next.init({+ lng: "en",+ resources: { en: { translation: { close: "Close" } } },+ });+});const renderNotification = (attributes: Partial<NotificationAttributes>) =>renderToStaticMarkup(@@ -62,3 +70,49 @@ describe("notification icons", () => {expect(noLeadingIconMarkup.match(/<svg\b/g)).toHaveLength(1);});});++describe("notification accessibility", () => {+ test.each([+ {+ title: "Renew now",+ caption: "Subscription expired",+ captionText: "Subscription expired",+ },+ {+ title: "Summer vacation",+ caption: <span>Downloading · 4 / 10 files</span>,+ captionText: "Downloading · 4 / 10 files",+ },+ ])(+ "exposes title and caption in the $title button",+ ({ title, caption, captionText }) => {+ const markup = renderNotification({+ title,+ caption,+ onClick: vi.fn(),+ endIcon: ReloadIcon,+ endIconLabel: "Retry",+ onEndIconClick: vi.fn(),+ });+ const buttons = [+ ...markup.matchAll(/<button\b([^>]*)>([\s\S]*?)<\/button>/g),+ ];+ expect(buttons).toHaveLength(3);+ const mainButton = buttons[0]!;+ const text = mainButton[2]!+ .replace(/<style\b[^>]*>[\s\S]*?<\/style>/g, "")+ .replace(/<[^>]*>/g, " ")+ .replace(/\s+/g, " ")+ .trim();+ expect(text).toBe(`${title} ${captionText}`);+ expect(mainButton[1]).not.toContain("aria-label=");+ const contentID = /id="([^"]+)" role="status"/.exec(+ mainButton[2]!,+ )?.[1];+ expect(contentID).toBeDefined();+ expect(mainButton[1]).toContain(`aria-labelledby="${contentID}"`);+ expect(buttons[1]![1]).toContain('aria-label="Retry"');+ expect(buttons[2]![1]).toContain('aria-label="Close"');+ },+ );+});diff --git a/web/packages/base/components/Notification.tsx b/web/packages/base/components/Notification.tsxindex ac8d68d12a..d443130ab2 100644--- a/web/packages/base/components/Notification.tsx+++ b/web/packages/base/components/Notification.tsx@@ -66,6 +66,7 @@ export const Notification: React.FC<NotificationProps> = ({attributes,keepOpenOnClick,}) => {+ const contentID = React.useId();if (!attributes) return <></>;const {@@ -128,6 +129,7 @@ export const Notification: React.FC<NotificationProps> = ({</Stack>)}<Stack+ id={contentID}role="status"sx={{flex: 1,@@ -202,9 +204,7 @@ export const Notification: React.FC<NotificationProps> = ({<RippleDisabledButtonvariant="text"color="inherit"- aria-label={- typeof title === "string" ? title : undefined- }+ aria-labelledby={contentID}onClick={handleClick}sx={{flex: 1,