Skip to content

Commit

Permalink
chore(component-library): announce tooltip content when focusing tool…
Browse files Browse the repository at this point in the history
…tip content
  • Loading branch information
Haberkamp committed Feb 5, 2025
1 parent 5180945 commit c5471b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-donkeys-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Announce tooltip content when focusing tooltip trigger
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe("mt-tooltip", () => {

// ACT & ASSERT
expect(screen.queryByRole("tooltip", { name: "Tooltip" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Open tooltip" })).not.toHaveAttribute(
"aria-describedby",
expect(screen.getByRole("button", { name: "Open tooltip" })).toHaveAccessibleDescription(
"Tooltip",
);
});

Expand Down Expand Up @@ -108,7 +108,7 @@ describe("mt-tooltip", () => {
},
);

it("does not announce the content of the tooltip when the tooltip is hidden", async () => {
it("does read out the tooltip content when focusing the trigger", async () => {
// ARRANGE
render(MtTooltip, {
props: {
Expand All @@ -123,10 +123,10 @@ describe("mt-tooltip", () => {
await flushPromises();

// ACT & ASSERT
expect(screen.getByRole("button", { name: "Open tooltip" })).not.toHaveAccessibleDescription(
expect(screen.getByRole("button", { name: "Open tooltip" })).toHaveAccessibleDescription(
"Tooltip",
);
expect(screen.getByRole("button", { name: "Open tooltip" })).not.toHaveAttribute(
expect(screen.getByRole("button", { name: "Open tooltip" })).toHaveAttribute(
"aria-describedby",
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
onMouseleave,
onMousedown,
onMouseup: () => setState({ isPressingTrigger: false }),
'aria-describedby': isVisible ? `mt-tooltip--${id}__tooltip` : undefined,
'aria-describedby': `mt-tooltip--${id}__tooltip`,
}"
/>

Expand Down

0 comments on commit c5471b3

Please sign in to comment.