Skip to content

Commit

Permalink
fix(TagsInput): fix a11y issues
Browse files Browse the repository at this point in the history
  • Loading branch information
plagoa authored and zettca committed Aug 18, 2023
1 parent a66b3cc commit 4948021
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions packages/core/src/components/TagsInput/TagsInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const Main: StoryObj<HvTagsInputProps> = {
label: "Enter your tags",
description: "This is where you enter your tags",
placeholder: "Enter value",
"aria-label": "The label",
disabled: false,
readOnly: false,
required: false,
Expand Down Expand Up @@ -76,41 +77,45 @@ export const Variants: StoryObj<HvTagsInputProps> = {
return (
<div className={css(styles.root)}>
<HvTagsInput
id="tags-list-5"
id="tags-list-variants-1"
label="Required"
aria-label="Required"
placeholder="Enter value"
required
value={[{ label: "tag 1" }, { label: "tag 2" }, { label: "tag 3" }]}
/>
<HvTagsInput
id="tags-list-6"
id="tags-list-variants-2"
label="Disabled"
aria-label="Disabled"
placeholder="Enter value"
disabled
value={[
{ label: "tag 1", disabled: true },
{ label: "tag 2", disabled: true },
{ label: "tag 3", disabled: true },
{ label: "tag 4", disabled: true },
{ label: "tag 5", disabled: true },
{ label: "tag 6", disabled: true },
]}
/>
<HvTagsInput
id="tags-list-7"
id="tags-list-variants-3"
label="Readonly"
aria-label="Readonly"
placeholder="Enter value"
readOnly
value={[{ label: "tag 1" }, { label: "tag 2" }, { label: "tag 3" }]}
value={[{ label: "tag 7" }, { label: "tag 8" }, { label: "tag 9" }]}
/>
<HvTagsInput
id="tags-list-8"
id="tags-list-variants-4"
label="Invalid"
aria-label="Invalid"
placeholder="Enter value"
status="invalid"
statusMessage="Oh no!"
value={[{ label: "tag 1" }, { label: "tag 2" }, { label: "tag 3" }]}
value={[
{ label: "tag 10" },
{ label: "tag 11" },
{ label: "tag 12" },
]}
/>
</div>
);
Expand Down Expand Up @@ -385,6 +390,7 @@ export const TagsCounterValidation: StoryObj<HvTagsInputProps> = {
maxTagsQuantity={3}
countCharProps={{
"aria-label": `You have inserted ${tagsLength} tags`,
role: "status",
}}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/TagsInput/TagsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ export const HvTagsInput = (props: HvTagsInputProps) => {
gutters: classes.listItemGutters,
root: classes.listItemRoot,
}}
id={`tag-${i}`}
id={setId(elementId, `tag-${i}`)}
>
<HvTag
label={label}
Expand Down Expand Up @@ -637,7 +637,7 @@ export const HvTagsInput = (props: HvTagsInputProps) => {
root: classes.tagInputContainerRoot,
gutters: classes.listItemGutters,
}}
id={`tag-${value.length}`}
id={setId(elementId, `tag-${value.length}`)}
>
<HvInput
value={tagInput}
Expand Down

0 comments on commit 4948021

Please sign in to comment.