Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FileUploadField fix to set name attribute on input element #9941

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
hideDefaultPreview?: boolean;
/** Unique id for the text area. Also used to generate ids for accessible labels. */
id: string;
/** Name property for the text input. */
name?: string;
/** Flag to disable the clear button. */
isClearButtonDisabled?: boolean;
/** Flag to show if the field is disabled. */
Expand Down Expand Up @@ -84,6 +86,7 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen

export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
id,
name,
Copy link
Contributor

@gitdallas gitdallas Jan 12, 2024

Choose a reason for hiding this comment

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

should there be a default value? it is currently (kind of/potentially) a breaking change as we are removing the {id}-filename default

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Can we make it a default value.

type,
value = '',
filename = '',
Expand Down Expand Up @@ -135,7 +138,7 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
readOnlyVariant="default" // Always read-only regardless of isReadOnly prop (which is just for the TextArea)
isDisabled={isDisabled}
id={`${id}-filename`}
name={`${id}-filename`}
name={name || `${id}-filename`}
aria-label={filenameAriaLabel}
placeholder={filenamePlaceholder}
aria-describedby={`${id}-browse-button`}
Expand Down Expand Up @@ -172,7 +175,6 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
resizeOrientation={TextAreResizeOrientation.vertical}
validated={validated}
id={id}
name={id}
aria-label={ariaLabel}
value={value as string}
onChange={onTextAreaChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ exports[`simple fileupload 1`] = `
aria-invalid="false"
aria-label="File upload"
id="simple-text-file"
name="simple-text-file"
placeholder=""
/>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ exports[`simple fileuploadfield 1`] = `
aria-invalid="false"
aria-label="File upload"
id="custom-file-upload"
name="custom-file-upload"
placeholder=""
/>
</span>
Expand Down
Loading