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

[terra-pills] Fixed JAWS(SR) providing navigation instructions on empty pill box #1935

Merged
merged 7 commits into from
Dec 8, 2023
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
1 change: 1 addition & 0 deletions packages/terra-framework-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Changed
* Changed terra-pills example to announce removed state of pills.
* Updated examples and tests for `terra-folder-tree`.

## 1.50.0 - (December 5, 2023)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const AppliedFiltersExample = () => {
};

const appliedFiltersLabel = 'Applied Filters:';
const appliedFiltersLabelId = 'terra-filter-pills-example-applied-filters-label';

return (
<>
Expand All @@ -41,7 +40,6 @@ const AppliedFiltersExample = () => {
<div className={cx('toolbar-flex-container')}>
<div className={cx('toolbar-flex-item-start')}>
<Text
id={appliedFiltersLabelId}
className={cx('applied-filters-label')}
>
{appliedFiltersLabel}
Expand All @@ -50,7 +48,6 @@ const AppliedFiltersExample = () => {
<div className={cx('toolbar-flex-item-fill')}>
<FilterPills
ariaLabel={appliedFiltersLabel}
ariaLabelledBy={appliedFiltersLabelId}
isCollapsible
onRemove={handleOnRemove}
>
Expand Down
2 changes: 2 additions & 0 deletions packages/terra-pills/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## Unreleased

* Fixed
* Fixed jaws providing navigation instructions on empty pill box.
* Fixed bug to set focus on previous pill when delete key is pressed and a pill is deleted.


## 1.15.0 - (November 23, 2023)

* Changed
Expand Down
21 changes: 12 additions & 9 deletions packages/terra-pills/src/FilterPills.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const FilterPills = (props) => {
const isPillDeleted = useRef(false);
const isRollUpRemoved = useRef(false);
const removedLabel = useRef();
const containerHint = useRef(ariaLabel);

// Identifies the number of pills that needs to be hidden/rolled up
const generateRollUp = useCallback(() => {
Expand Down Expand Up @@ -379,7 +378,7 @@ const FilterPills = (props) => {
if (isCollapsible && (rollUpCount > 0) && isCollapsed) {
pillGroupInteractionHint += `, ${intl.formatMessage({ id: 'Terra.pills.hint.rollupNotVisible' }, { pillsNotVisibleCount: rollUpCount })}`;
} else if (isCollapsible && !isCollapsed && showRollupPillInteraction) {
removedPillInteractionHint = intl.formatMessage({ id: 'Terra.pills.hint.rollupVisible' });
pillGroupInteractionHint = intl.formatMessage({ id: 'Terra.pills.hint.rollupVisible' });
}
if (pillRemoved) {
removedPillInteractionHint = intl.formatMessage({ id: 'Terra.pills.hint.wasRemoved' }, { pillLabelName: removedLabel.current });
Expand All @@ -398,24 +397,28 @@ const FilterPills = (props) => {
return reducedArray;
};

const ariaLabelHint = (!ariaLabelledBy) ? `${removedPillInteractionHint}, ${ariaLabel}` : undefined;
const ariaAttrs = (React.Children.count(children)) ? {
'aria-live': 'assertive',
'aria-label': ariaLabelHint,
'aria-labelledby': ariaLabelledBy,
'aria-describedby': pillGroupAriaDescribedBy,
role: 'list',
tabIndex: containerTabindex,
} : { role: 'group' };

return (
<div
{...customProps}
{...filterPillsProps}
aria-live="assertive"
aria-label={!ariaLabelledBy ? `${removedPillInteractionHint} ${containerHint.current}` : undefined}
aria-labelledby={ariaLabelledBy}
aria-describedby={pillGroupAriaDescribedBy}
{...ariaAttrs}
className={pillListClassNames}
ref={filterPillsRef}
role="list"
tabIndex={containerTabindex}
>
<VisuallyHiddenText
aria-live="polite"
id={pillGroupInteractionHintID}
text={pillGroupInteractionHint}
aria-hidden="true"
/>
{children ? renderChildren(children) : []}
{(isCollapsible && rollUpCount > 0) && (
Expand Down
Loading