Skip to content

Commit

Permalink
fix: accessible-tooltips (#344)
Browse files Browse the repository at this point in the history
* fix: add role to react tooltip and add a aria title

* hide tooltip on press escape

* add changeset

* avoid using aria-label

* Fix class to className in Tooltip component
  • Loading branch information
Barthélémy Ledoux authored Nov 16, 2023
1 parent 2868018 commit 4fcb9f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/a11y-tooltips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@cypress-design/react-tooltip": patch
"@cypress-design/vue-tooltip": patch
---

fix: accessible-tooltips
2 changes: 2 additions & 0 deletions components/Tooltip/react/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const Tooltip: React.FC<
...(interactive ? { padding: '16px' } : {}),
},
})}
role="tooltip"
>
<div
className={clsx('rounded shadow-tooltip border', [
Expand Down Expand Up @@ -225,6 +226,7 @@ export const Tooltip: React.FC<
colors.background,
)}
>
<span className="sr-only">Tooltip: </span>
{popper}
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/Tooltip/vue/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ onMounted(() => {
@focus="placeTooltip"
@blur="show = false"
@mouseout="show = false"
@keydown.escape="show = false"
>
<!-- @slot element to hover on to open the tooltip -->
<slot />
Expand Down Expand Up @@ -246,6 +247,7 @@ onMounted(() => {
class="rounded text-[16px] leading-[24px] min-w-[160px] text-center p-[8px] relative z-20"
:class="colors.background"
>
<span class="sr-only">Tooltip: </span>
<!-- @slot content of the tooltip -->
<slot name="popper" />
</div>
Expand Down

1 comment on commit 4fcb9f6

@vercel
Copy link

@vercel vercel bot commented on 4fcb9f6 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.