Skip to content

Commit

Permalink
fix(file-uploade): add error aria state (uber#2937)
Browse files Browse the repository at this point in the history
  • Loading branch information
tajo authored Feb 28, 2020
1 parent 9ca755d commit 940b394
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions documentation-site/components/yard/config/file-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ const FileUploaderConfig: TConfig = {
description: 'Name attribute.',
hidden: true,
},
['aria-describedby']: {
value: undefined,
type: PropTypes.String,
description: `Sets aria-describedby attribute.`,
hidden: true,
},
overrides: {
value: undefined,
type: PropTypes.Custom,
Expand Down
7 changes: 7 additions & 0 deletions src/file-uploader/file-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ function FileUploader(props: PropsT) {
onClick={() => {
props.onRetry && props.onRetry();
}}
aria-invalid={Boolean(props.errorMessage)}
aria-describedby={props['aria-describedby']}
aria-errormessage={props.errorMessage}
overrides={{
BaseButton: {
style: {outline: null, fontWeight: 'normal'},
Expand All @@ -196,6 +199,7 @@ function FileUploader(props: PropsT) {
onClick={() => {
props.onCancel && props.onCancel();
}}
aria-describedby={props['aria-describedby']}
overrides={{
BaseButton: {
style: {outline: null, fontWeight: 'normal'},
Expand All @@ -210,6 +214,9 @@ function FileUploader(props: PropsT) {
</FileDragAndDrop>

<HiddenInput
aria-invalid={Boolean(props.errorMessage) || null}
aria-describedby={props['aria-describedby']}
aria-errormessage={props.errorMessage || null}
{...getInputProps()}
{...prefixedStyledProps}
{...hiddenInputProps}
Expand Down
1 change: 1 addition & 0 deletions src/file-uploader/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type PropsT = {|
onDropRejected?: DropFileEventHandlerT,
onFileDialogCancel?: () => mixed,
preventDropOnDocument?: boolean,
'aria-describedby'?: string,

// Error message to be displayed
errorMessage?: string,
Expand Down

0 comments on commit 940b394

Please sign in to comment.