From d482b46c035e5332499e84030b18f049a56e2670 Mon Sep 17 00:00:00 2001 From: Une Sofie Kinn Ekroll Date: Mon, 18 May 2026 15:59:47 +0200 Subject: [PATCH 1/7] fix(Tooltip): only set `aria-label` if there is no accessible text --- .changeset/fuzzy-cooks-rush.md | 5 ++ .../components/tooltip/tooltip.stories.tsx | 37 ++++++++++++- .../react/src/components/tooltip/tooltip.tsx | 53 +++++++++++++++++-- 3 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 .changeset/fuzzy-cooks-rush.md diff --git a/.changeset/fuzzy-cooks-rush.md b/.changeset/fuzzy-cooks-rush.md new file mode 100644 index 0000000000..6a998cb844 --- /dev/null +++ b/.changeset/fuzzy-cooks-rush.md @@ -0,0 +1,5 @@ +--- +"@digdir/designsystemet-react": patch +--- + +**Tooltip**: the React component will no longer override existing accessible text. It now correctly sets `aria-description` in that case. If there is no accessible text, `aria-label` will be used as before. diff --git a/packages/react/src/components/tooltip/tooltip.stories.tsx b/packages/react/src/components/tooltip/tooltip.stories.tsx index 6557b94658..9c38430c95 100644 --- a/packages/react/src/components/tooltip/tooltip.stories.tsx +++ b/packages/react/src/components/tooltip/tooltip.stories.tsx @@ -2,7 +2,7 @@ import { FilesIcon } from '@navikt/aksel-icons'; import type { Meta, StoryFn, StoryObj } from '@storybook/react-vite'; import { useEffect, useRef, useState } from 'react'; import { expect, within } from 'storybook/test'; -import { Button } from '../../'; +import { Button, Link } from '../../'; import { Tooltip } from './tooltip'; type Story = StoryObj; @@ -44,6 +44,33 @@ Preview.args = { placement: 'top', }; +export const WithLink = () => { + return ( + + En lenke + + ); +}; +WithLink.play = () => {}; + +export const WithSpan = () => { + return ( + + Tekst med tooltip + + ); +}; +WithSpan.play = () => {}; + +export const WithPlainText = () => { + return ( + + Tekst med tooltip + + ); +}; +WithPlainText.play = () => {}; + export const WithString: Story = { args: { content: 'Organisasjonsnummer', @@ -67,9 +94,15 @@ export const Placement: Story = { export const Aria: StoryFn = () => { return ( <> - + + + +