Skip to content
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

Jaws text area #16890

Closed
wants to merge 10 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,6 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
return changes;
case InputBlur:
case InputKeyDownEscape:
setInputFocused(false);
setInputValue('');
setIsOpen(false);
return changes;
case FunctionToggleMenu:
Expand Down Expand Up @@ -714,6 +712,10 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
}
},
onFocus: () => setInputFocused(true),
onBlur: () => {
!isOpen && setInputFocused(false);
setInputValue('');
},
})
);
const menuProps = getMenuProps({}, { suppressRefError: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ describe('FilterableMultiSelect', () => {
expect(screen.getByPlaceholderText('test')).toHaveDisplayValue(3);
});

it('should clear input value when clicking on cross button', async () => {
render(<FilterableMultiSelect {...mockProps} placeholder="test" />);
await openMenu();

await userEvent.type(screen.getByPlaceholderText('test'), '3');

const clearButton = screen.getByRole('button', {
name: 'Clear selected item',
});
await userEvent.click(clearButton);

expect(screen.getByPlaceholderText('test')).toHaveDisplayValue('');
});

it('should respect slug prop', async () => {
const { container } = render(
<FilterableMultiSelect {...mockProps} slug={<Slug />} />
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,12 @@ const TextArea = React.forwardRef((props: TextAreaProps, forwardRef) => {
)}
{input}
{normalizedSlug}
<span className={`${prefix}--text-area__counter-alert`} role="alert">
<span
className={`${prefix}--text-area__counter-alert`}
role="alert"
aria-atomic="true"
// aria-live="polite"
>
{ariaAnnouncement}
</span>
{isFluid && <hr className={`${prefix}--text-area__divider`} />}
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/internal/useAnnouncer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

export function useAnnouncer(textCount, maxCount, entityName = 'characters') {
const lastTen = maxCount - 10;
if (textCount == maxCount) {
return `Maximum ${entityName} reached.`;
}
if (textCount >= lastTen) {
return `${maxCount - textCount} ${entityName} left.`;
}
Expand Down
Loading