Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(editor): show a choice row's tooltip only for icon-only options
EtienneLescotf7b96fcd8bde
diff --git a/src/components/ai-edition/ChoiceRow.test.tsx b/src/components/ai-edition/ChoiceRow.test.tsxindex f5aa7e969..1756fffa4 100644--- a/src/components/ai-edition/ChoiceRow.test.tsx+++ b/src/components/ai-edition/ChoiceRow.test.tsx@@ -43,3 +43,74 @@ describe("ChoiceRow keyboard", () => {expect(screen.getByRole("button", { name: "one" })).toHaveFocus();});});++// A tooltip that says what the button already says is noise (tooltips.md, rule 3). A button with+// no visible label is the one that needs it: it is named for a screen reader and for the mouse.+describe("ChoiceRow tooltips", () => {+ const icon = <svg aria-hidden="true" />;++ it("draws no tooltip on an option whose label is visible", () => {+ render(+ <ChoiceRow<string>+ label="row"+ value="a"+ onChange={vi.fn()}+ options={[+ { value: "a", label: "Alpha" },+ { value: "b", label: "Beta" },+ ]}+ />,+ );+ for (const name of ["Alpha", "Beta"]) {+ expect(screen.getByRole("button", { name })).not.toHaveAttribute("title");+ }+ });++ it("names an icon-only option in its tooltip", () => {+ render(+ <ChoiceRow<string>+ label="row"+ value="a"+ onChange={vi.fn()}+ options={[+ { value: "a", label: "Alpha", icon },+ { value: "b", label: "Beta", icon },+ ]}+ />,+ );+ expect(screen.getByRole("button", { name: "Alpha" })).toHaveAttribute("title", "Alpha");+ expect(screen.getByRole("button", { name: "Beta" })).toHaveAttribute("title", "Beta");+ });++ it("draws no tooltip on an option that shows its icon and its label", () => {+ render(+ <ChoiceRow<string>+ label="row"+ display="both"+ value="a"+ onChange={vi.fn()}+ options={[{ value: "a", label: "Alpha", icon }]}+ />,+ );+ expect(screen.getByRole("button", { name: "Alpha" })).not.toHaveAttribute("title");+ });++ it("keeps the tooltip a caller passes, even beside a visible label", () => {+ render(+ <ChoiceRow<string>+ label="row"+ value="a"+ onChange={vi.fn()}+ options={[+ { value: "a", label: "Alpha", title: "Alpha · 2 clips" },+ { value: "b", label: "Beta" },+ ]}+ />,+ );+ expect(screen.getByRole("button", { name: "Alpha" })).toHaveAttribute(+ "title",+ "Alpha · 2 clips",+ );+ expect(screen.getByRole("button", { name: "Beta" })).not.toHaveAttribute("title");+ });+});diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex 1e309160e..aa7868edb 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -3974,7 +3974,9 @@ export function ChoiceRow<T extends string | number>({label: string;/** `null` leaves a hole in the grid: the middle of the camera's position grid. An option* can be `disabled` on its own: a disabled button takes no focus, so its `title` is only a- * mouse hint, and the reason must also be visible text the row points at (`describedBy`). */+ * mouse hint, and the reason must also be visible text the row points at (`describedBy`).+ * `title` is a tooltip that adds to the label (a clip count). An icon-only option gets its+ * label as its tooltip; one whose label is visible gets none. */options: ReadonlyArray<{value: T;label: string;@@ -4044,8 +4046,10 @@ export function ChoiceRow<T extends string | number>({className={`${styles.choiceBtn} ${pressed ? styles.isActive : ""}`}aria-pressed={pressed}aria-label={mode === "icon" ? option.label : undefined}- // Always: a label cut short by a narrow pane still reads in full on hover.- title={option.title ?? option.label}+ // Only where it tells something the button does not: the name of an icon-only+ // option, or the text a caller passes. A visible label is never repeated+ // (technical-documentation/engineering/tooltips.md, rule 3).+ title={option.title ?? (mode === "icon" ? option.label : undefined)}disabled={disabled || option.disabled}// Re-choisir la valeur en place n'est pas une modification : ni sauvegarde ni// entrée d'annulation.