From 72aa36ad1351f70058adb70351157c85322090ef Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 1 Oct 2024 10:16:06 -0400 Subject: [PATCH] Avoid chaining aria-labelledby on tooltips aria-labelledby cannot be chained (https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby#benefits_and_drawbacks). So, it's not good practice to be setting aria-labelledby on both the anchor and the tooltip element. The basic issue that I believe initially motivated the chaining was to distinguish the caption from the main tooltip content (by setting both aria-labelledby and aria-describedby on the tooltip element), so that the caption would not be considered part of the anchor's accessible label. But this was never actually working. The only good solution seems to be setting aria-labelledby and aria-describedby on the anchor to point directly to the label and caption elements. --- .../__snapshots__/EditInPlace.test.tsx.snap | 48 +++++++++---------- src/components/Tooltip/Tooltip.test.tsx | 14 +++--- src/components/Tooltip/Tooltip.tsx | 2 - src/components/Tooltip/useTooltip.ts | 13 ++--- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/components/Form/Controls/EditInPlace/__snapshots__/EditInPlace.test.tsx.snap b/src/components/Form/Controls/EditInPlace/__snapshots__/EditInPlace.test.tsx.snap index bc715a5c..83b5aa4f 100644 --- a/src/components/Form/Controls/EditInPlace/__snapshots__/EditInPlace.test.tsx.snap +++ b/src/components/Form/Controls/EditInPlace/__snapshots__/EditInPlace.test.tsx.snap @@ -10,7 +10,7 @@ exports[`EditInPlace > disables control when disabled 1`] = ` > @@ -20,7 +20,7 @@ exports[`EditInPlace > disables control when disabled 1`] = ` @@ -40,7 +40,7 @@ exports[`EditInPlace > displays saved label for 2 seconds after save 1`] = ` > @@ -49,7 +49,7 @@ exports[`EditInPlace > displays saved label for 2 seconds after save 1`] = ` > @@ -71,7 +71,7 @@ exports[`EditInPlace > displays saved label for 2 seconds after save 2`] = ` @@ -79,11 +79,11 @@ exports[`EditInPlace > displays saved label for 2 seconds after save 2`] = ` class="_controls_980156" > @@ -92,7 +92,7 @@ exports[`EditInPlace > displays saved label for 2 seconds after save 2`] = ` >