Skip to content

fix: added resultsCountContext prop to pass into the screenReaderText… #11844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/react-core/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,15 @@ $ yarn test

Ensure no lint errors are introduced in `yarn-error.log` after running this command.

5. Add a commit using `yarn commit`:
5. Add a commit using `git commit`:

This project uses [`lerna`](https://lernajs.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow this convention for your commit messages.

You can use `commitizen` to help you to follow [the convention][3].
This project uses [`lerna`](https://lerna.js.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow [`this convention`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type) for your commit messages.

Once you are ready to commit the changes, please use the below commands:

```text
$ git add <files to be committed>
$ yarn commit
$ git commit -m
```

... and follow the instruction of the interactive prompt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
/** The number of search results returned. Either a total number of results,
* or a string representing the current result over the total number of results. i.e. "1 / 5". */
resultsCount?: number | string;
/** Screenreader text that will appear after resultsCount to give context for what that value represents to assistive technologies. */
resultsCountContext?: string;
/** Label for the button which calls the onSearch event handler. */
submitSearchButtonLabel?: string;
/** Value of the search input. */
Expand All @@ -144,6 +146,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
onToggleAdvancedSearch,
isAdvancedSearchOpen = false,
resultsCount,
resultsCountContext = ' results',
onNextClick,
onPreviousClick,
innerRef,
Expand Down Expand Up @@ -309,7 +312,11 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
/>
{(renderUtilities || areUtilitiesDisplayed) && (
<TextInputGroupUtilities>
{resultsCount && <Badge isRead>{resultsCount}</Badge>}
{resultsCount && (
<Badge isRead screenReaderText={resultsCountContext}>
{resultsCount}
</Badge>
)}
{!!onNextClick && !!onPreviousClick && (
<div className={textInputGroupStyles.textInputGroupGroup}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ describe('Search Input Demo Test', () => {
cy.get('#enabled-search .pf-v6-c-text-input-group__utilities > button').should('be.visible');
cy.get('#enabled-search .pf-v6-c-text-input-group__group').should('be.visible');

cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '1 / 3');
cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '1 / 3 results');
cy.get('#enabled-search .pf-v6-c-text-input-group__group button').last().click();
cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '2 / 3');
cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '2 / 3 results');
cy.get('#enabled-search .pf-v6-c-text-input-group__group button').first().click();
cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '1 / 3');
cy.get('#enabled-search .pf-v6-c-badge').should('have.text', '1 / 3 results');

cy.get('#enabled-search .pf-v6-c-text-input-group__utilities > button').click();
cy.get('#enabled-search .pf-v6-c-text-input-group__text-input').should('not.have.value', 'Hello world');
Expand Down
Loading