TypeScript
fix: composer hero reads project name to screen readers (#12397)
Khai Shern, Toh45e06f48a033
diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsxindex 9732ed6865f..681f6c5ee52 100644--- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx+++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx@@ -1455,7 +1455,7 @@ export function NewTaskDraftScreen(props: {<Text className="text-2xl font-t3-medium tracking-tight text-foreground">in </Text><PressableaccessibilityHint="Opens the project picker"- accessibilityLabel={`Change project from ${selectedProject.title}`}+ accessibilityLabel={selectedProject.title}accessibilityRole="button"disabled={isComposerInteractionLocked}onPress={chooseProject}diff --git a/apps/web/src/components/chat/DraftHeroHeadline.tsx b/apps/web/src/components/chat/DraftHeroHeadline.tsxindex 07956c2b299..d542cd6a8a9 100644--- a/apps/web/src/components/chat/DraftHeroHeadline.tsx+++ b/apps/web/src/components/chat/DraftHeroHeadline.tsx@@ -136,10 +136,11 @@ export function DraftHeroHeadline({<Tooltip><TooltipTriggerrender={- <MenuTrigger- aria-label={hasResolvedProject ? "Change project" : "Choose a project"}- className="pointer-events-auto inline-block max-w-64 truncate border-foreground/60 border-b border-dotted align-baseline text-foreground transition-colors hover:border-foreground/80 focus-visible:rounded-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"- />+ // The trigger's accessible name comes from its visible text (the+ // project title) so the hero sentence reads naturally: an+ // aria-label here would replace the title with an action phrase+ // mid-sentence and baffle screen-reader users.+ <MenuTrigger className="pointer-events-auto inline-block max-w-64 truncate border-foreground/60 border-b border-dotted align-baseline text-foreground transition-colors hover:border-foreground/80 focus-visible:rounded-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring" />}>{activeProjectDisplayName ?? "Choose a project"}@@ -233,8 +234,21 @@ export function DraftHeroHeadline({</button>);+ // The composer hero is a sentence, so the heading's accessible name must be+ // a complete sentence too. The project picker is a control rendered inline+ // in the h1; without an explicit label its widget state bleeds into the+ // announced phrase.+ const headingLabel = hasResolvedProject+ ? `What should we build in ${activeProjectDisplayName}?`+ : canChooseProject+ ? `${activeProjectDisplayName ?? "Choose a project"} to start`+ : "Add a project to start";+return (- <h1 className="mx-auto w-full max-w-5xl text-center font-normal text-2xl text-foreground tracking-tight sm:text-3xl">+ <h1+ aria-label={headingLabel}+ className="mx-auto w-full max-w-5xl text-center font-normal text-2xl text-foreground tracking-tight sm:text-3xl"+ >{hasResolvedProject ? (<>What should we build in {projectSelector}?</>) : canChooseProject ? (