Add aria label hint for keyboard deletion of chat attachments#299785
Merged
meganrogge merged 5 commits intomainfrom Mar 11, 2026
Merged
Add aria label hint for keyboard deletion of chat attachments#299785meganrogge merged 5 commits intomainfrom
meganrogge merged 5 commits intomainfrom
Conversation
When a chat attachment supports deletion (Delete/Backspace), the aria label now includes ", press Delete to remove from context" so screen reader users can discover this keyboard shortcut. Fixes accessibility issue where there was no way to discover how to remove attached context files via keyboard. Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix keyboard accessibility for removing attached context files
Add aria label hint for keyboard deletion of chat attachments
Mar 6, 2026
Collaborator
|
@copilot, it should just say (Delete) in parens, not that long message |
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves accessibility for screen reader users in VS Code's Chat panel by adding a deletion hint to the aria labels of chat attachment widgets. When an attachment supports keyboard deletion (Delete/Backspace), its aria label now includes ", press Delete to remove from context" so screen reader users can discover this capability.
Changes:
- Added
_hasClearButtonflag andappendDeletionHint()helper method toAbstractChatAttachmentWidgetbase class, which appends a localized deletion hint only when the clear button is active. - Set
_hasClearButton = trueinsideattachClearButton()to track whether deletion is supported. - Updated 12 of the 13 attachment widget subclasses to pipe their aria labels through
appendDeletionHint().
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.ts:445
- In
ImageAttachmentWidget,appendDeletionHintis called withthis.element.ariaLabel ?? ''even though the localariaLabelvariable (defined earlier in the constructor) is still in scope and would be more direct and robust. Reading fromthis.element.ariaLabelis fragile because it depends oncreateImageElementshaving set it; a future refactor of that function could silently break the hint.
this.element.ariaLabel = this.appendDeletionHint(this.element.ariaLabel ?? '');
src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.ts:936
- In
NotebookCellOutputChatAttachmentWidget.renderImageOutput,appendDeletionHintis called withthis.element.ariaLabel ?? ''even though the localariaLabelvariable is still in scope. Using the local variable directly is more robust: it doesn't depend oncreateImageElementshaving setelement.ariaLabel.
this.element.ariaLabel = this.appendDeletionHint(this.element.ariaLabel ?? '');
src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.ts
Outdated
Show resolved
Hide resolved
…ntWidgets.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…l patterns Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
meganrogge
approved these changes
Mar 11, 2026
dmitrivMS
approved these changes
Mar 11, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Screen reader users had no way to discover that Delete/Backspace removes attached context files in Chat.
Adds a
(Delete)suffix to attachment aria labels when deletion is supported. The hint is gated on the same conditions as the existing keyboard handler (supportsDeletion && !attachment.range)._hasClearButtonflag andappendDeletionHint()helper inAbstractChatAttachmentWidgetappendDeletionHint()PromptTextAttachmentWidgetImageAttachmentWidgetandNotebookCellOutputChatAttachmentWidget.renderImageOutputto pass localariaLabelvariable directly toappendDeletionHint()instead of reading back fromthis.element.ariaLabelBefore:
"Attached file, main.ts /src"After:
"Attached file, main.ts /src (Delete)"💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.