Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-search-field] Remove redundant search group #4019

Merged
merged 15 commits into from
Feb 8, 2024

Conversation

KV106606Viswanath
Copy link
Contributor

Summary

When the search field input gets focussed, screen reader reads the unnecessary search group such as "Search, Search region, Search group, Search edit field". With this fix redundant announcement of search group has been removed.

What was changed:
Redundant announcement of search group has been removed.

Why it was changed:

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-10147


Thank you for contributing to Terra.
@cerner/terra

@KV106606Viswanath KV106606Viswanath requested a review from a team as a code owner January 24, 2024 06:55
@KV106606Viswanath KV106606Viswanath self-assigned this Jan 24, 2024
@ShettyAkarsh
Copy link
Contributor

@KV106606Viswanath please add the before and after evidence.

@@ -268,7 +268,6 @@ class SearchField extends React.Component {
);

const inputAriaLabelText = inputAttributes && Object.prototype.hasOwnProperty.call(inputAttributes, 'aria-label') ? inputAttributes['aria-label'] : intl.formatMessage({ id: 'Terra.searchField.search' });
const groupNameValue = groupName === 'Search' ? intl.formatMessage({ id: 'Terra.searchField.search' }) : groupName;
Copy link
Contributor

@saket2403 saket2403 Jan 29, 2024

Choose a reason for hiding this comment

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

This line allows users to set custom aria-label via groupName prop. Removing this breaks that functionality. Pls test this example on SR https://engineering.cerner.com/terra-ui/components/cerner-terra-core-docs/search-field/examples/search-field-with-no-label. Before and after your change. It should announce the custom aria label

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing "groupName" prop to input field that should announce the custom visual label.

<div className={cx('input-group')}>
<input
{...additionalInputAttributes}
className={inputClass}
type="search"
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel even this should not be removed . See Here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search. It should announce like this. Changing default aria label (groupName default value) should be the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@@ -104,7 +104,7 @@ const propTypes = {
const defaultProps = {
defaultValue: undefined,
disableAutoSearch: false,
groupName: 'Search',
groupName: 'Search a clinic',
Copy link
Contributor

Choose a reason for hiding this comment

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

Did someone from UX ask to change this value to search a clinic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to discuss with UX regarding this default value and add translations also for whatever text is finalised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted default groupName to "Search".

@@ -21,7 +21,7 @@ Terra.describeViewports('Search Field', ['medium'], () => {
});

it('should display Search Field with scrolled text', () => {
expect($('input[type="search"]').isFocused()).toBeTruthy();
expect($('input').isFocused()).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since type=search has been added back these wdio spec changes can be reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@@ -2,6 +2,9 @@

## Unreleased

* Fixed
* Removed unnecessary aria labels and roles to fix redundant announcement of serach group issue.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Removed unnecessary aria labels and roles to fix redundant announcement of serach group issue.
* Removed unnecessary aria labels and roles to fix redundant announcement of search group issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

@saket2403 saket2403 Jan 31, 2024

Choose a reason for hiding this comment

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

Please add back type=search for all the tests. You just reverted for one of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@saket2403
Copy link
Contributor

Can you update the tests also with a visible label?

@KV106606Viswanath
Copy link
Contributor Author

Can you update the tests also with a visible label?

Updated.

<div role="search" className={cx('search-role-container')} aria-label={intl.formatMessage({ id: 'Terra.searchField.search' })}>
<div role="group" aria-label={groupNameValue} {...customProps} className={searchFieldClassNames}>
<div className={cx('search-role-container')}>
<div role="group" aria-label={intl.formatMessage({ id: 'Terra.searchField.search' })} {...customProps} className={searchFieldClassNames}>
Copy link
Contributor

Choose a reason for hiding this comment

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

what will be the screen reader response when groupName is Search. ( since this div and input will have same value for aria-label attribute will it result in redundant response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's causing redundant response of "Search".

Copy link
Contributor

@supreethmr supreethmr Feb 6, 2024

Choose a reason for hiding this comment

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

then we should remove the default value of search from input aria-label to avoid the redundant response

@supreethmr
Copy link
Contributor

@KV106606Viswanath groupName prop of terra-search-field has a non-internationalised string Search as default value which is incorrect. Is there different Jira to make default value of groupName prop to be internationalised string ?

@KV106606Viswanath
Copy link
Contributor Author

@KV106606Viswanath groupName prop of terra-search-field has a non-internationalised string Search as default value which is incorrect. Is there different Jira to make default value of groupName prop to be internationalised string ?

No, we don't have any separate jira for this, we already have internationalised string for "Search" as "Terra.searchField.search": "Search".

@rbsree
Copy link

rbsree commented Feb 5, 2024

+1, as recommended a contextual and practical label is provided to the Search Edit field and the Search field along with the button is grouped.

@supreethmr
Copy link
Contributor

@KV106606Viswanath groupName prop of terra-search-field has a non-internationalised string Search as default value which is incorrect. Is there different Jira to make default value of groupName prop to be internationalised string ?

No, we don't have any separate jira for this, we already have internationalised string for "Search" as "Terra.searchField.search": "Search".

Can update the prop description of groupName to indicate default value Search is being used when no value is provided.

Copy link
Contributor

@supreethmr supreethmr left a comment

Choose a reason for hiding this comment

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

Jest snapshots are not updated for recent code changes, needs update !!

@github-actions github-actions bot temporarily deployed to preview-pr-4019 February 8, 2024 04:25 Destroyed
@saket2403 saket2403 merged commit c55faac into main Feb 8, 2024
22 checks passed
@saket2403 saket2403 deleted the KV106606-Remove-redundant-search-group branch February 8, 2024 04:50
@KV106606Viswanath KV106606Viswanath added the ⭐ Accessibility Reviewed Accessibility has been reviewed and approved. label Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⭐ Accessibility Reviewed Accessibility has been reviewed and approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants