Skip to content

Commit

Permalink
fix(Popover): use visible title for popup a11y label
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov authored Nov 11, 2024
1 parent b5de671 commit 5f40912
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';

import {Xmark} from '@gravity-ui/icons';

import {useUniqId} from '../../hooks/useUniqId'

Check failure on line 7 in src/components/Popover/Popover.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `;`
import {Button} from '../Button';
import {Icon} from '../Icon';
import type {PopupPlacement} from '../Popup';
Expand Down Expand Up @@ -115,6 +116,8 @@ export const Popover = React.forwardRef<PopoverInstanceProps, PopoverProps & QAP

const hasTitle = Boolean(title);

const popoverTitleId = `popover-${tooltipId ?? ''}-title-${useUniqId()}`;

const tooltip = (
<Popup
id={tooltipId}
Expand Down Expand Up @@ -144,9 +147,10 @@ export const Popover = React.forwardRef<PopoverInstanceProps, PopoverProps & QAP
restoreFocus={true}
restoreFocusRef={restoreFocusRef || controlRef}
modifiers={modifiers}
aria-labelledby={title ? popoverTitleId : undefined}
>
<React.Fragment>
{title && <h3 className={cnPopover('tooltip-title')}>{title}</h3>}
{title && <h3 id={popoverTitleId} className={cnPopover('tooltip-title')}>{title}</h3>}

Check failure on line 153 in src/components/Popover/Popover.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `<h3·id={popoverTitleId}·className={cnPopover('tooltip-title')}>{title}</h3>` with `(⏎····················<h3·id={popoverTitleId}·className={cnPopover('tooltip-title')}>⏎························{title}⏎····················</h3>⏎················)`
<Content
secondary={hasTitle ? theme !== 'announcement' : false}
content={content}
Expand Down

0 comments on commit 5f40912

Please sign in to comment.