Skip to content

Commit 2dab51f

Browse files
FileUploadField fix to set name attribute on input element (#9941)
* FileUploadField name attribute fix * update snapshots * prevent breaking change --------- Co-authored-by: nicolethoen <[email protected]>
1 parent 10a26e6 commit 2dab51f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/react-core/src/components/FileUpload/FileUploadField.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
3737
hideDefaultPreview?: boolean;
3838
/** Unique id for the text area. Also used to generate ids for accessible labels. */
3939
id: string;
40+
/** Name property for the text input. */
41+
name?: string;
4042
/** Flag to disable the clear button. */
4143
isClearButtonDisabled?: boolean;
4244
/** Flag to show if the field is disabled. */
@@ -84,6 +86,7 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
8486

8587
export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
8688
id,
89+
name,
8790
type,
8891
value = '',
8992
filename = '',
@@ -135,7 +138,7 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
135138
readOnlyVariant="default" // Always read-only regardless of isReadOnly prop (which is just for the TextArea)
136139
isDisabled={isDisabled}
137140
id={`${id}-filename`}
138-
name={`${id}-filename`}
141+
name={name || `${id}-filename`}
139142
aria-label={filenameAriaLabel}
140143
placeholder={filenamePlaceholder}
141144
aria-describedby={`${id}-browse-button`}
@@ -172,7 +175,6 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
172175
resizeOrientation={TextAreResizeOrientation.vertical}
173176
validated={validated}
174177
id={id}
175-
name={id}
176178
aria-label={ariaLabel}
177179
value={value as string}
178180
onChange={onTextAreaChange}

packages/react-core/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ exports[`simple fileupload 1`] = `
7676
aria-invalid="false"
7777
aria-label="File upload"
7878
id="simple-text-file"
79-
name="simple-text-file"
8079
placeholder=""
8180
/>
8281
</span>

packages/react-core/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ exports[`simple fileuploadfield 1`] = `
7474
aria-invalid="false"
7575
aria-label="File upload"
7676
id="custom-file-upload"
77-
name="custom-file-upload"
7877
placeholder=""
7978
/>
8079
</span>

0 commit comments

Comments
 (0)