-
Notifications
You must be signed in to change notification settings - Fork 13.9k
feat(a11y): Add live region to announce contextual bar search results #39847
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
93290d8
feat(a11y): add ResultsLiveRegion component for improved accessibilit…
dougfabris 62b66d0
chore: ts
dougfabris bc70bac
feat(a11y): enhance RoomFiles component with accessibility improvemen…
dougfabris 1029e47
feat(a11y): update RoomMembers component for improved accessibility
dougfabris 0d86d30
feat(a11y): add DiscussionsList component with accessibility tests an…
dougfabris cbe568f
chore: revert changes in `MessageSearch`
dougfabris 098248b
chore: remove unnecessary spaces in files
dougfabris 04fa9d8
feat(a11y): improve accessibility in ThreadList component by updating…
dougfabris 3f8e584
feat(a11y): enhance MessageSearchTab with accessibility improvements …
dougfabris 6ab8a92
feat(a11y): update incorrect aria-label in RoomMembers component
dougfabris 98945e2
feat(a11y): update ResultsLiveRegion to use total item count for bett…
dougfabris 3a7855f
feat(a11y): add itemCount to Default and Empty states
dougfabris fb782f8
chore: update snapshots
dougfabris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { VisuallyHidden } from 'react-aria'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| const ResultsLiveRegion = ({ shouldAnnounce, itemCount }: { shouldAnnounce: boolean; itemCount: number }) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| if (itemCount === 0) { | ||
| return <VisuallyHidden role='status'>{shouldAnnounce && t('No_results_found')}</VisuallyHidden>; | ||
| } | ||
|
|
||
| return <VisuallyHidden role='status'>{shouldAnnounce && t('__count__result_found', { count: itemCount })}</VisuallyHidden>; | ||
| }; | ||
|
|
||
| export default ResultsLiveRegion; |
24 changes: 24 additions & 0 deletions
24
apps/meteor/client/views/room/contextualBar/Discussions/DiscussionsList.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { composeStories } from '@storybook/react'; | ||
| import { render } from '@testing-library/react'; | ||
| import { axe } from 'jest-axe'; | ||
|
|
||
| import * as stories from './DiscussionsList.stories'; | ||
|
|
||
| jest.mock('../../../../lib/rooms/roomCoordinator', () => ({ | ||
| roomCoordinator: { | ||
| getRoomDirectives: jest.fn(() => ({})), | ||
| }, | ||
| })); | ||
|
|
||
| const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]); | ||
| test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => { | ||
| const { baseElement } = render(<Story />); | ||
| expect(baseElement).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => { | ||
| const { container } = render(<Story />); | ||
|
|
||
| const results = await axe(container); | ||
| expect(results).toHaveNoViolations(); | ||
| }); |
55 changes: 55 additions & 0 deletions
55
apps/meteor/client/views/room/contextualBar/Discussions/DiscussionsList.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Contextualbar } from '@rocket.chat/ui-client'; | ||
| import { action } from '@storybook/addon-actions'; | ||
| import type { Meta, StoryFn } from '@storybook/react'; | ||
|
|
||
| import DiscussionsList from './DiscussionsList'; | ||
|
|
||
| export default { | ||
| component: DiscussionsList, | ||
| parameters: { | ||
| layout: 'fullscreen', | ||
| actions: { argTypesRegex: '^on.*' }, | ||
| }, | ||
| decorators: [(fn) => <Contextualbar height='100vh'>{fn()}</Contextualbar>], | ||
| args: { | ||
| text: '', | ||
| loadMoreItems: action('loadMoreItems'), | ||
| }, | ||
| } satisfies Meta<typeof DiscussionsList>; | ||
|
|
||
| const Template: StoryFn<typeof DiscussionsList> = (args) => <DiscussionsList {...args} />; | ||
|
|
||
| const fakeDiscussions = Array.from({ length: 10 }, (_, i) => ({ | ||
| _id: String(i), | ||
| msg: `Discussion ${i}`, | ||
| ts: new Date('2024-01-01T00:00:00Z'), | ||
| username: 'user.name', | ||
| dcount: 5, | ||
| dlm: new Date('2024-01-01T00:00:00Z'), | ||
| drid: `drid-${i}`, | ||
| rid: 'roomId', | ||
| _updatedAt: new Date('2024-01-01T00:00:00Z'), | ||
| u: { | ||
| _id: 'user-id', | ||
| username: 'user.name', | ||
| }, | ||
| })); | ||
|
|
||
| export const Default = Template.bind({}); | ||
| Default.args = { | ||
| isSuccess: true, | ||
| discussions: fakeDiscussions, | ||
| itemCount: fakeDiscussions.length, | ||
| }; | ||
|
|
||
| export const Loading = Template.bind({}); | ||
| Loading.args = { | ||
| isPending: true, | ||
| }; | ||
|
|
||
| export const Empty = Template.bind({}); | ||
| Empty.args = { | ||
| isSuccess: true, | ||
| discussions: [], | ||
| itemCount: 0, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.