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

fix: add aria-label for removing attachment in new request form #543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 31 additions & 1 deletion assets/flash-notifications-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,488 changes: 1,446 additions & 42 deletions assets/new-request-form-bundle.js

Large diffs are not rendered by default.

3,482 changes: 3,481 additions & 1 deletion assets/new-request-form-translations-bundle.js

Large diffs are not rendered by default.

35,293 changes: 35,269 additions & 24 deletions assets/shared-bundle.js

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion assets/wysiwyg-bundle.js

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/modules/new-request-form/fields/attachments/Attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Input,
Label,
Message,
FileList,
} from "@zendeskgarden/react-forms";
import {
Close,
Expand Down Expand Up @@ -202,15 +203,17 @@ export function Attachments({ field }: AttachmentProps): JSX.Element {
)}
<Input {...getInputProps()} />
</FileUpload>
{files.map((file) => (
<FileListItem
key={file.status === "pending" ? file.id : file.value.id}
file={file}
onRemove={() => {
handleRemove(file);
}}
/>
))}
<FileList>
{files.map((file) => (
<FileListItem
key={file.status === "pending" ? file.id : file.value.id}
file={file}
onRemove={() => {
handleRemove(file);
}}
/>
))}
</FileList>
{files.map(
(file) =>
file.status === "uploaded" && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,26 @@ export function FileListItem({

return (
<FileList.Item>
<File type="generic" title={fileName} onKeyDown={handleFileKeyDown}>
<File
type="generic"
tabIndex={0}
aria-label={t(
"new-request-form.attachments.file",
"File: {{fileName}}, press delete to remove",
{ fileName }
)}
onKeyDown={handleFileKeyDown}
>
{file.status === "pending" ? (
<>
<FileNameWrapper>{fileName}</FileNameWrapper>
<Tooltip content={stopUploadLabel}>
<File.Close
aria-label={stopUploadLabel}
aria-label={t(
"new-request-form.attachments.stop-upload-aria-label",
"Stop uploading {{fileName}}",
{ fileName }
)}
Comment on lines +73 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add aria-describedby={undefined} to avoid a duplicate screen reader announcement here, too?

Suggested change
aria-label={t(
"new-request-form.attachments.stop-upload-aria-label",
"Stop uploading {{fileName}}",
{ fileName }
)}
aria-label={t(
"new-request-form.attachments.stop-upload-aria-label",
"Stop uploading {{fileName}}",
{ fileName }
)}
aria-describedby={undefined}
  • Current screen reader announcement: Stop uploading [file name], Stop uploading, button
  • Expected screen reader announcement: Stop uploading [file name], button

(The word "button" comes from it being an HTML button element.)

onClick={() => {
onRemove();
}}
Expand All @@ -86,7 +99,11 @@ export function FileListItem({
</FileNameWrapper>
<Tooltip content={removeFileLabel}>
<File.Delete
aria-label={removeFileLabel}
aria-label={t(
"new-request-form.attachments.remove-file-arria-label",
"Remove file: {{fileName}}",
{ fileName }
)}
Comment on lines +102 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add aria-describedby={undefined} here? That way, the screen reader won't read out the "Remove file" text from the tooltip after it reads out the name of the button.

Suggested change
aria-label={t(
"new-request-form.attachments.remove-file-arria-label",
"Remove file: {{fileName}}",
{ fileName }
)}
aria-label={t(
"new-request-form.attachments.remove-file-arria-label",
"Remove file: {{fileName}}",
{ fileName }
)}
aria-describedby={undefined}
  • Current screen reader announcement: Remove file: [file name], Remove file, button
  • Expected screen reader announcement: Remove file: [file name], button

(The word "button" comes from it being an HTML button element.)

onClick={() => {
onRemove();
}}
Expand Down
15 changes: 15 additions & 0 deletions src/modules/new-request-form/translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,26 @@ parts:
title: "Tooltip for the button for removing an attachment"
screenshot: "https://drive.google.com/file/d/1JFVE2twzUkg-U6gGAs2EHqD-3jPvtJDA/view?usp=drive_link"
value: "Remove file"
- translation:
key: "new-request-form.attachments.stop-upload-aria-label"
title: "[A11Y] Hidden label for screen readers for stopping the upload of an attachment. {{fileName}} will be replaced by file name, e.g., [image.png]. Alternative English if you encounter declension issues: [Stop uploading the file {{fileName}}]"
screenshot: "https://drive.google.com/file/d/1Y6yeqp3fbfJbuq7tT8VutsLa80GZju-V/view?usp=drive_link"
value: "Stop uploading {{fileName}}"
- translation:
key: "new-request-form.attachments.remove-file-aria-label"
title: "[A11Y] Hidden label for screen readers for removing an attachment. {{fileName}} will be replaced by file name, e.g., [image.png]. Alternative English if you encounter declension issues: [Removing the file {{fileName}}]"
screenshot: "https://drive.google.com/file/d/1JFVE2twzUkg-U6gGAs2EHqD-3jPvtJDA/view?usp=drive_link"
value: "Remove file: {{fileName}}"
- translation:
key: "new-request-form.attachments.uploading"
title: "[A11Y] Hidden label for screen readers for the upload attachment progress bar. {{fileName}} will be replaced by file name, e.g., [image.png]. Alternative English if you encounter declension issues: [Uploading the file {{fileName}}]"
screenshot: "https://drive.google.com/file/d/1Y6yeqp3fbfJbuq7tT8VutsLa80GZju-V/view?usp=drive_link"
value: "Uploading {{fileName}}"
- translation:
key: "new-request-form.attachments.file"
title: "[A11Y] Hidden label for screen readers informing how they can remove the file with keyboard navigation. {{fileName}} will be replaced by file name, e.g., [image.png]. Alternative English if you encounter declension issues: [Press Delete to remove the file {{fileName}}]"
screenshot: "https://drive.google.com/file/d/1JFVE2twzUkg-U6gGAs2EHqD-3jPvtJDA/view?usp=drive_link"
value: "File: {{fileName}}, press delete to remove"
- translation:
key: "new-request-form.submit"
title: "Submit button for the New Request Form"
Expand Down
Loading