Skip to content

Commit d96668a

Browse files
fix: added resultsCountContext prop to pass into the screenReaderText… (#11844)
* fix: added resultsCountContext prop to pass into the screenReaderText prop * fix: updated contributing markdown * fix: changed integration tests and fixed results duplication * fix: removed unnecessary dependencies and modified integration tests * Update packages/react-core/src/components/SearchInput/SearchInput.tsx Co-authored-by: Eric Olkowski <[email protected]> --------- Co-authored-by: Eric Olkowski <[email protected]>
1 parent 729b137 commit d96668a

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

packages/react-core/CONTRIBUTING.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,15 @@ $ yarn test
7979

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

82-
5. Add a commit using `yarn commit`:
82+
5. Add a commit using `git commit`:
8383

84-
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.
85-
86-
You can use `commitizen` to help you to follow [the convention][3].
84+
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.
8785

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

9088
```text
9189
$ git add <files to be committed>
92-
$ yarn commit
90+
$ git commit -m
9391
```
9492

9593
... and follow the instruction of the interactive prompt.

packages/react-core/src/components/SearchInput/SearchInput.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
118118
/** The number of search results returned. Either a total number of results,
119119
* or a string representing the current result over the total number of results. i.e. "1 / 5". */
120120
resultsCount?: number | string;
121+
/** Screenreader text that will appear after resultsCount to give context for what that value represents to assistive technologies. */
122+
resultsCountContext?: string;
121123
/** Label for the button which calls the onSearch event handler. */
122124
submitSearchButtonLabel?: string;
123125
/** Value of the search input. */
@@ -144,6 +146,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
144146
onToggleAdvancedSearch,
145147
isAdvancedSearchOpen = false,
146148
resultsCount,
149+
resultsCountContext = ' results',
147150
onNextClick,
148151
onPreviousClick,
149152
innerRef,
@@ -309,7 +312,11 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
309312
/>
310313
{(renderUtilities || areUtilitiesDisplayed) && (
311314
<TextInputGroupUtilities>
312-
{resultsCount && <Badge isRead>{resultsCount}</Badge>}
315+
{resultsCount && (
316+
<Badge isRead screenReaderText={resultsCountContext}>
317+
{resultsCount}
318+
</Badge>
319+
)}
313320
{!!onNextClick && !!onPreviousClick && (
314321
<div className={textInputGroupStyles.textInputGroupGroup}>
315322
<Button

packages/react-integration/cypress/integration/searchinput.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ describe('Search Input Demo Test', () => {
3636
cy.get('#enabled-search .pf-v6-c-text-input-group__utilities > button').should('be.visible');
3737
cy.get('#enabled-search .pf-v6-c-text-input-group__group').should('be.visible');
3838

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

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

0 commit comments

Comments
 (0)