Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
fix: expand delete label for Pill, #noissue
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahHouben committed Nov 17, 2021
1 parent 80c96be commit 6f92029
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Pill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ const Pill = forwardRef((props, ref) => {
background,
children,
deleteLabel,
getDeleteLabel = (children, deleteLabel) =>
`${deleteLabel} "${children}"`,
dimmed,
forwardedAs,
icon,
Expand Down Expand Up @@ -291,7 +293,7 @@ const Pill = forwardRef((props, ref) => {
}

const {marginProps, filteredProps} = splitMarginProps(otherProps);

const uniqueDeleteLabel = getDeleteLabel(children, deleteLabel);
return (
<ConditionalFlexWrapper wrap={hasSideButton} {...marginProps}>
<Wrapper
Expand Down Expand Up @@ -330,7 +332,7 @@ const Pill = forwardRef((props, ref) => {
color="shaded"
background={background}
onClick={onDelete}
aria-label={deleteLabel}
aria-label={uniqueDeleteLabel}
/>
)}
</ConditionalFlexWrapper>
Expand Down Expand Up @@ -385,6 +387,11 @@ Pill.propTypes = {
* Accessible label for the delete button.
*/
deleteLabel: PropTypes.string,
/**
* Customise the accessible label for the delete button.
* Uses the children and the `deleteLabel`property.
*/
getDeleteLabel: PropTypes.func,
};

export default Pill;

0 comments on commit 6f92029

Please sign in to comment.