From 8d708a43023eb274df419544482c1e5a2714209f Mon Sep 17 00:00:00 2001 From: LarryMatte Date: Tue, 4 Jun 2024 15:47:03 -0400 Subject: [PATCH] fix(tag): fix a11y et arialabel (#883) * fix(tag): fix a11y et arialabel * fix(tag): fix translation --- .../src/components/tag/tag.test.tsx.snap | 180 ++++++++---------- packages/react/src/components/tag/tag.tsx | 5 +- packages/react/src/i18n/translations.ts | 4 +- 3 files changed, 88 insertions(+), 101 deletions(-) diff --git a/packages/react/src/components/tag/tag.test.tsx.snap b/packages/react/src/components/tag/tag.test.tsx.snap index 0d82708e14..0c2f0b5960 100644 --- a/packages/react/src/components/tag/tag.test.tsx.snap +++ b/packages/react/src/components/tag/tag.test.tsx.snap @@ -153,7 +153,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (desktop remov width: 1rem; } - - + `; exports[`Tag Tag size=medium color=decorative-01 matches snapshot (desktop with icons) 1`] = ` @@ -218,7 +217,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (desktop with width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=decorative-01 matches snapshot (desktop) 1`] = ` @@ -271,7 +270,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (desktop) 1`] white-space: nowrap; } - Test - + `; exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile removable) 1`] = ` @@ -435,7 +434,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile remova width: 1rem; } - - + `; exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile with icons) 1`] = ` @@ -500,7 +498,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile with i width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile) 1`] = ` @@ -553,7 +551,7 @@ exports[`Tag Tag size=medium color=decorative-01 matches snapshot (mobile) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop removable) 1`] = ` @@ -717,7 +715,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop remov width: 1rem; } - - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop with icons) 1`] = ` @@ -782,7 +779,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop with width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop) 1`] = ` @@ -835,7 +832,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (desktop) 1`] white-space: nowrap; } - Test - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile removable) 1`] = ` @@ -999,7 +996,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile remova width: 1rem; } - - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile with icons) 1`] = ` @@ -1064,7 +1060,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile with i width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile) 1`] = ` @@ -1117,7 +1113,7 @@ exports[`Tag Tag size=medium color=decorative-02 matches snapshot (mobile) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=medium color=default matches snapshot (desktop removable) 1`] = ` @@ -1281,7 +1277,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (desktop removable) width: 1rem; } - - + `; exports[`Tag Tag size=medium color=default matches snapshot (desktop with icons) 1`] = ` @@ -1346,7 +1341,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (desktop with icons) width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=default matches snapshot (desktop) 1`] = ` @@ -1399,7 +1394,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (desktop) 1`] = ` white-space: nowrap; } - Test - + `; exports[`Tag Tag size=medium color=default matches snapshot (mobile removable) 1`] = ` @@ -1563,7 +1558,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (mobile removable) 1 width: 1rem; } - - + `; exports[`Tag Tag size=medium color=default matches snapshot (mobile with icons) 1`] = ` @@ -1628,7 +1622,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (mobile with icons) width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=medium color=default matches snapshot (mobile) 1`] = ` @@ -1681,7 +1675,7 @@ exports[`Tag Tag size=medium color=default matches snapshot (mobile) 1`] = ` white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop removable) 1`] = ` @@ -1846,7 +1840,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop remova width: 1rem; } - - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop with icons) 1`] = ` @@ -1911,7 +1904,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop with i width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop) 1`] = ` @@ -1964,7 +1957,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (desktop) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile removable) 1`] = ` @@ -2128,7 +2121,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile removab width: 1rem; } - - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile with icons) 1`] = ` @@ -2193,7 +2185,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile with ic width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile) 1`] = ` @@ -2246,7 +2238,7 @@ exports[`Tag Tag size=small color=decorative-01 matches snapshot (mobile) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop removable) 1`] = ` @@ -2411,7 +2403,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop remova width: 1rem; } - - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop with icons) 1`] = ` @@ -2476,7 +2467,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop with i width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop) 1`] = ` @@ -2529,7 +2520,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (desktop) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile removable) 1`] = ` @@ -2693,7 +2684,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile removab width: 1rem; } - - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile with icons) 1`] = ` @@ -2758,7 +2748,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile with ic width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile) 1`] = ` @@ -2811,7 +2801,7 @@ exports[`Tag Tag size=small color=decorative-02 matches snapshot (mobile) 1`] = white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=default matches snapshot (desktop removable) 1`] = ` @@ -2976,7 +2966,7 @@ exports[`Tag Tag size=small color=default matches snapshot (desktop removable) 1 width: 1rem; } - - + `; exports[`Tag Tag size=small color=default matches snapshot (desktop with icons) 1`] = ` @@ -3041,7 +3030,7 @@ exports[`Tag Tag size=small color=default matches snapshot (desktop with icons) width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=default matches snapshot (desktop) 1`] = ` @@ -3094,7 +3083,7 @@ exports[`Tag Tag size=small color=default matches snapshot (desktop) 1`] = ` white-space: nowrap; } - Test - + `; exports[`Tag Tag size=small color=default matches snapshot (mobile removable) 1`] = ` @@ -3258,7 +3247,7 @@ exports[`Tag Tag size=small color=default matches snapshot (mobile removable) 1` width: 1rem; } - - + `; exports[`Tag Tag size=small color=default matches snapshot (mobile with icons) 1`] = ` @@ -3323,7 +3311,7 @@ exports[`Tag Tag size=small color=default matches snapshot (mobile with icons) 1 width: var(--size-1x); } - Test - + `; exports[`Tag Tag size=small color=default matches snapshot (mobile) 1`] = ` @@ -3376,7 +3364,7 @@ exports[`Tag Tag size=small color=default matches snapshot (mobile) 1`] = ` white-space: nowrap; } - Test - + `; diff --git a/packages/react/src/components/tag/tag.tsx b/packages/react/src/components/tag/tag.tsx index 677af1aaf9..3f1fff3df2 100644 --- a/packages/react/src/components/tag/tag.tsx +++ b/packages/react/src/components/tag/tag.tsx @@ -94,7 +94,7 @@ function getTagColors( return theme.component[`tag-${$tagColor}-${$colorProperty}`]; } -const TagContainer = styled.span` +const TagContainer = styled.div` align-items: center; background-color: ${(props) => getTagColors(props, 'background-color')}; border: 1px solid ${(props) => getTagColors(props, 'border-color')}; @@ -152,7 +152,7 @@ export const Tag = forwardRef(({ color = 'default', value, onRemove, -}: TagProps, ref: Ref) => { +}: TagProps, ref: Ref) => { const { t } = useTranslation('tag'); const { isMobile } = useDeviceContext(); @@ -204,7 +204,6 @@ export const Tag = forwardRef(({ {isRemovable && (