Skip to content

Commit

Permalink
[core] fix(Tag): improve a11y label (#5437)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt authored Jul 12, 2022
1 parent 00c7595 commit 81147fc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/core/src/components/tag/tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export interface ITagProps
export class Tag extends AbstractPureComponent2<TagProps> {
public static displayName = `${DISPLAYNAME_PREFIX}.Tag`;

private tagId = Utils.uniqueId("tag");

public render() {
const {
active,
Expand Down Expand Up @@ -172,10 +174,22 @@ export class Tag extends AbstractPureComponent2<TagProps> {
) : null;

return (
<span {...htmlProps} className={tagClasses} tabIndex={interactive ? tabIndex : undefined} ref={elementRef}>
<span
{...htmlProps}
aria-labelledby={this.tagId}
className={tagClasses}
tabIndex={interactive ? tabIndex : undefined}
ref={elementRef}
>
<Icon icon={icon} />
{!isReactNodeEmpty(children) && (
<Text className={Classes.FILL} ellipsize={!multiline} tagName="span" title={htmlTitle}>
<Text
className={Classes.FILL}
ellipsize={!multiline}
id={this.tagId}
tagName="span"
title={htmlTitle}
>
{children}
</Text>
)}
Expand Down

1 comment on commit 81147fc

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[core] fix(Tag): improve a11y label (#5437)

Previews: documentation | landing | table | demo

Please sign in to comment.