-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: Screen reader not announcing Adaptive Card content in stacked layout #5784
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
Open
uzirthapa
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
uzirthapa:fix/adaptive-card-screen-reader-a11y
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d794c41
fix: Screen reader not announcing Adaptive Card content in stacked la…
uzirthapa 4531376
fix: Use inset outline-offset so focus ring is visible inside overflo…
uzirthapa 7c4c2f8
Revert "fix: Use inset outline-offset so focus ring is visible inside…
uzirthapa bae084c
test: Add e2e tests for Adaptive Card screen reader a11y fix
uzirthapa 997e9ee
fix: Address lint errors in a11y changes
uzirthapa 7ddd99e
fix: Address lint errors in a11y changes
uzirthapa 7898912
ci: Retrigger CI to verify flaky useTextBox test
uzirthapa a7899ae
fix: Use tabIndex={-1} to avoid breaking focus traps in Adaptive Cards
uzirthapa 86d283f
ci: Retrigger CI for flaky useTextBox test
uzirthapa 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
Some comments aren't visible on the classic Files Changed page.
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
87 changes: 87 additions & 0 deletions
87
__tests__/html2/accessibility/adaptiveCard/attachmentRow.focusable.html
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,87 @@ | ||
| <!doctype html> | ||
| <html lang="en-US"> | ||
| <head> | ||
| <link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
| <script crossorigin="anonymous" src="/test-harness.js"></script> | ||
| <script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
| <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script> | ||
| run(async function () { | ||
| const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
|
||
| WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| attachments: [ | ||
| { | ||
| content: { | ||
| type: 'AdaptiveCard', | ||
| $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
| version: '1.5', | ||
| body: [ | ||
| { | ||
| type: 'TextBlock', | ||
| text: 'First card content' | ||
| } | ||
| ] | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| } | ||
| ] | ||
| }); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| attachments: [ | ||
| { | ||
| content: { | ||
| type: 'AdaptiveCard', | ||
| $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
| version: '1.5', | ||
| body: [ | ||
| { | ||
| type: 'TextBlock', | ||
| text: 'Second card content' | ||
| } | ||
| ] | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| } | ||
| ] | ||
| }); | ||
|
|
||
| await pageConditions.numActivitiesShown(2); | ||
|
|
||
| const attachmentRows = document.querySelectorAll('[aria-roledescription="attachment"]'); | ||
|
|
||
| // Both attachment rows should be programmatically focusable via tabIndex="-1". | ||
| expect(attachmentRows).toHaveProperty('length', 2); | ||
| expect(attachmentRows[0].getAttribute('tabindex')).toBe('-1'); | ||
| expect(attachmentRows[1].getAttribute('tabindex')).toBe('-1'); | ||
|
|
||
| // Both should have role="group". | ||
| expect(attachmentRows[0].getAttribute('role')).toBe('group'); | ||
| expect(attachmentRows[1].getAttribute('role')).toBe('group'); | ||
|
|
||
| // Focus on the first attachment row and verify it receives focus. | ||
| attachmentRows[0].focus(); | ||
|
|
||
| await pageConditions.became( | ||
| 'focus is on the first attachment row', | ||
| () => document.activeElement === attachmentRows[0], | ||
| 1000 | ||
| ); | ||
|
|
||
| // The Adaptive Card inside should have an aria-label derived from text content. | ||
| const card = attachmentRows[0].querySelector('.ac-adaptiveCard'); | ||
|
|
||
| expect(card.getAttribute('aria-label')).toContain('First card content'); | ||
| expect(card.getAttribute('role')).toBeTruthy(); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
95 changes: 95 additions & 0 deletions
95
__tests__/html2/accessibility/adaptiveCard/hack.roleMod.ariaLabelFromTextContent.html
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,95 @@ | ||
| <!doctype html> | ||
| <html lang="en-US"> | ||
| <head> | ||
| <link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
| <script crossorigin="anonymous" src="/test-harness.js"></script> | ||
| <script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
| <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script> | ||
| run(async function () { | ||
| const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
|
||
| WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| attachments: [ | ||
| { | ||
| content: { | ||
| type: 'AdaptiveCard', | ||
| $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
| version: '1.5', | ||
| body: [ | ||
| { | ||
| type: 'TextBlock', | ||
| text: 'Flight Status Update' | ||
| }, | ||
| { | ||
| type: 'TextBlock', | ||
| text: 'Flight AA1234 from Seattle to New York' | ||
| } | ||
| ] | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| }, | ||
| { | ||
| content: { | ||
| type: 'AdaptiveCard', | ||
| $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
| version: '1.5', | ||
| speak: 'Custom speak text for screen readers', | ||
| body: [ | ||
| { | ||
| type: 'TextBlock', | ||
| text: 'This text should not be the aria-label' | ||
| } | ||
| ] | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| }, | ||
| { | ||
| content: { | ||
| type: 'AdaptiveCard', | ||
| $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', | ||
| version: '1.5', | ||
| body: [ | ||
| { | ||
| type: 'Input.Text', | ||
| id: 'name', | ||
| label: 'Your Name', | ||
| placeholder: 'Enter your name' | ||
| } | ||
| ] | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| } | ||
| ] | ||
| }); | ||
|
|
||
| await pageConditions.numActivitiesShown(1); | ||
|
|
||
| const [cardNoSpeak, cardWithSpeak, cardFormNoSpeak] = Array.from( | ||
| document.querySelectorAll('.ac-adaptiveCard') | ||
| ); | ||
|
|
||
| // Card without speak: aria-label should be derived from visible text content. | ||
| expect(cardNoSpeak.getAttribute('aria-label')).toContain('Flight Status Update'); | ||
| expect(cardNoSpeak.getAttribute('aria-label')).toContain('Flight AA1234'); | ||
| expect(cardNoSpeak.getAttribute('role')).toBe('figure'); | ||
|
|
||
| // Card with speak: aria-label should use the speak property value. | ||
| expect(cardWithSpeak.getAttribute('aria-label')).toBe('Custom speak text for screen readers'); | ||
| expect(cardWithSpeak.getAttribute('role')).toBe('figure'); | ||
|
|
||
| // Card with form inputs and no speak: aria-label should be derived from text content, | ||
| // and role should be "form" because it has inputs and an aria-label. | ||
| expect(cardFormNoSpeak.getAttribute('aria-label')).toBeTruthy(); | ||
| expect(cardFormNoSpeak.getAttribute('role')).toBe('form'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
&:focus { outline: 0; }rule removes the default focus indicator, but the custom outline is only applied in:focus-visible. In browsers that don’t support:focus-visible(or when it doesn’t match), this leaves the attachment row with no visible focus indicator. Consider either removing the:focusoutline reset, or providing a non-:focus-visiblefallback (e.g., apply the indicator on:focusand optionally suppress it with:focus:not(:focus-visible)).