Skip to content

Commit

Permalink
fix: add aria-label for DefinitionList help popover (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyzyl-ool authored Jul 11, 2024
1 parent b94ee82 commit ad93fec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export default {
id: 'color-contrast',
enabled: false,
},
{
id: 'definition-list', // todo: https://github.com/gravity-ui/components/issues/207
enabled: false,
},
],
},
},
Expand Down
18 changes: 17 additions & 1 deletion src/components/DefinitionList/components/Term.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import {HelpPopover} from '../../HelpPopover';
import i18n from '../i18n';
import {DefinitionListDirection, DefinitionListItemNote, DefinitionListSingleItem} from '../types';
import {b, getTitle} from '../utils';

Expand All @@ -19,12 +20,27 @@ function NoteElement({note}: NoteElementsProps) {
className={popoverClassName}
content={note}
placement={['bottom', 'top']}
buttonProps={{
'aria-label': i18n('label_note'),
}}
/>
);
}

if (typeof note === 'object') {
return <HelpPopover className={popoverClassName} placement={['bottom', 'top']} {...note} />;
const {buttonProps, ...rest} = note;

return (
<HelpPopover
className={popoverClassName}
placement={['bottom', 'top']}
buttonProps={{
'aria-label': i18n('label_note'),
...buttonProps,
}}
{...rest}
/>
);
}
return null;
}
Expand Down

0 comments on commit ad93fec

Please sign in to comment.