Skip to content

chore(textInputGroup): add unique aria labels to examples - #7713

Merged
thatblindgeye merged 8 commits into
patternfly:mainfrom
Mash707:text-input-group-add-aria-labels
Aug 19, 2025
Merged

thatblindgeye merged 8 commits into
patternfly:mainfrom
Mash707:text-input-group-add-aria-labels

Conversation

@Mash707

@Mash707 Mash707 commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

fixes: #7289

@Mash707

Mash707 commented Aug 1, 2025 •

Copy link
Copy Markdown
Contributor Author

@thatblindgeye For now I have added aria-labels to text-input-group-main but I think we should rather add these to text-input-group-text-input since it adds a aria-label by default (this means that there are two aria-labels which I think we should not have). Let me know what you think.

aria-label="
{{~#if text-input-group-text-input--aria-label~}}
{{text-input-group-text-input--aria-label}}
{{~else if text-input-group--IsDisabled~}}
Disabled text input group example input
{{~else~}}
Type to filter
{{~/if}}"

Based on the response I'll update the remaining examples.

@patternfly-build

patternfly-build commented Aug 1, 2025 •

Copy link
Copy Markdown
Collaborator

@thatblindgeye thatblindgeye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One file comment below, and just the following:

  • For the "Search input group, advanced search expanded" and "Search input group, advanced search expanded with autocomplete" examples, can we just tweak the "Submit" and "Reset" buttons in the examples so those have unique accessible names? We can keep it simple and apply unique ID's to the buttons themselves, then give each button an aria-labelledby that points to itself and the example heading (in that order). The end result should be an accessible name of "Submit Search input group, advanced search expanded" and so on.

{{#> badge badge--modifier="pf-m-read"}}
<span aria-hidden="true">{{text-input-group--search-input--count}}</span>
{{#> screen-reader}}
{{#if text-input-group--search-input--IsNavigable}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the "Search input group, match with navigable options" doesnt have this passed into it

@Mash707
Mash707 requested a review from thatblindgeye August 18, 2025 19:21
@thatblindgeye
thatblindgeye requested a review from mcoker August 18, 2025 19:39

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great to me! Just a few small tweaks if you don't mind.

Comment on lines +5 to +9
{{#if text-input-group--search-input--aria-label}}
{{> text-input-group-text-input text-input-group-text-input--aria-label=text-input-group--search-input--aria-label }}
{{else}}
{{> text-input-group-text-input text-input-group-text-input--aria-label="Search input" }}
{{/if}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW we do have a ternary helper for handlebars that would make this less code

/** Using ternary
if custom value for select--width: {{#> select select--width='160px'}}Filter by name{{/select}}
else custom value for select--width: {{#> select)}}Filter by name{{/select}}
{{#> select select--id=(concat toolbar--id '-select-name') select--width=(ternary toolbar-items-search-filter--width toolbar-items-search-filter--width '175px') select-toggle--icon="fas fa-filter"}}
{{> toolbar-item-search-filter toolbar-items-search-filter--width="300px"}}
*/
export const ternary = (testValue, trueValue, fallback) => {
return testValue ? trueValue : fallback;
};

Suggested change
{{#if text-input-group--search-input--aria-label}}
{{> text-input-group-text-input text-input-group-text-input--aria-label=text-input-group--search-input--aria-label }}
{{else}}
{{> text-input-group-text-input text-input-group-text-input--aria-label="Search input" }}
{{/if}}
{{> text-input-group-text-input text-input-group-text-input--aria-label=(ternary text-input-group--search-input--aria-label text-input-group--search-input--aria-label 'Search input' }}

Comment on lines +42 to +56
{{#if text-input-group--search-input--clear-button-aria-label}}
{{> button
button--IsPlain=true
button--IsIcon=true
button--icon="times fa-fw"
button--aria-label=text-input-group--search-input--clear-button-aria-label
}}
{{else}}
{{> button
button--IsPlain=true
button--IsIcon=true
button--icon="times fa-fw"
button--aria-label="Clear input"
}}
{{/if}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd use a ternary here, too

Suggested change
{{#if text-input-group--search-input--clear-button-aria-label}}
{{> button
button--IsPlain=true
button--IsIcon=true
button--icon="times fa-fw"
button--aria-label=text-input-group--search-input--clear-button-aria-label
}}
{{else}}
{{> button
button--IsPlain=true
button--IsIcon=true
button--icon="times fa-fw"
button--aria-label="Clear input"
}}
{{/if}}
{{> button
button--IsPlain=true
button--IsIcon=true
button--icon="times fa-fw"
button--aria-label=(ternary text-input-group--search-input--clear-button-aria-label text-input-group--search-input--clear-button-aria-label "Clear input")
}}

### Search input group, match with navigable options
```hbs
{{> text-input-group--search-input text-input-group--id="text-input-group-search-input-group-match-with-navigable-options" text-input-group-text-input--placeholder="Find by name" text-input-group--value="John Doe" text-input-group--search-input--count="1 / 3" text-input-group--search-input--IsFirstMatch="true"}}
{{> text-input-group--search-input text-input-group--id="text-input-group-search-input-group-match-with-navigable-options" text-input-group-text-input--placeholder="Find by name" text-input-group--value="John Doe" text-input-group--search-input--count="1 / 3" text-input-group--search-input--IsFirstMatch="true" text-input-group--search-input--IsNavigable="true" text-input-group--search-input--aria-label="Search input group match with navigable options" text-input-group--search-input--clear-button-aria-label="Clear search input group match with navigable options"}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The tiniest nittiest nit, just use true instead of "true" for setting something to true, unless you need to use the string "true" for some reason. In this case it should just be true. Our code is a little inconsistent that way, but we're trying to write all new code omitting the quotes unless you're passing a string to the parameter/attribute.

Suggested change
{{> text-input-group--search-input text-input-group--id="text-input-group-search-input-group-match-with-navigable-options" text-input-group-text-input--placeholder="Find by name" text-input-group--value="John Doe" text-input-group--search-input--count="1 / 3" text-input-group--search-input--IsFirstMatch="true" text-input-group--search-input--IsNavigable="true" text-input-group--search-input--aria-label="Search input group match with navigable options" text-input-group--search-input--clear-button-aria-label="Clear search input group match with navigable options"}}
{{> text-input-group--search-input text-input-group--id="text-input-group-search-input-group-match-with-navigable-options" text-input-group-text-input--placeholder="Find by name" text-input-group--value="John Doe" text-input-group--search-input--count="1 / 3" text-input-group--search-input--IsFirstMatch="true" text-input-group--search-input--IsNavigable=true text-input-group--search-input--aria-label="Search input group match with navigable options" text-input-group--search-input--clear-button-aria-label="Clear search input group match with navigable options"}}

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀

@thatblindgeye
thatblindgeye merged commit afa1921 into patternfly:main Aug 19, 2025
4 checks passed
@Mash707
Mash707 deleted the text-input-group-add-aria-labels branch August 22, 2025 19:28
@patternfly-build

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.3.0-prerelease.51 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextInputGroup - examples should use unique aria-labeling

4 participants