Skip to content

Commit 57f5823

Browse files
authored
fix(FileUploadField): don't render empty dom node (#12236)
1 parent 937bd3e commit 57f5823

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,31 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
172172
</InputGroupItem>
173173
</InputGroup>
174174
</div>
175-
<div className={styles.fileUploadFileDetails}>
176-
{!hideDefaultPreview && type === fileReaderType.text && (
177-
<TextArea
178-
readOnly={isReadOnly || (!!filename && !allowEditingUploadedText)}
179-
disabled={isDisabled}
180-
isRequired={isRequired}
181-
resizeOrientation={TextAreResizeOrientation.vertical}
182-
validated={validated}
183-
id={id}
184-
aria-label={ariaLabel}
185-
value={value as string}
186-
onChange={onTextAreaChange}
187-
onClick={onTextAreaClick}
188-
onBlur={onTextAreaBlur}
189-
placeholder={textAreaPlaceholder}
190-
/>
191-
)}
192-
{isLoading && (
193-
<div className={styles.fileUploadFileDetailsSpinner}>
194-
<Spinner size={spinnerSize.lg} aria-valuetext={spinnerAriaValueText} />
195-
</div>
196-
)}
197-
</div>
175+
{(isLoading || (!hideDefaultPreview && type === fileReaderType.text)) && (
176+
<div className={styles.fileUploadFileDetails}>
177+
{!hideDefaultPreview && type === fileReaderType.text && (
178+
<TextArea
179+
readOnly={isReadOnly || (!!filename && !allowEditingUploadedText)}
180+
disabled={isDisabled}
181+
isRequired={isRequired}
182+
resizeOrientation={TextAreResizeOrientation.vertical}
183+
validated={validated}
184+
id={id}
185+
aria-label={ariaLabel}
186+
value={value as string}
187+
onChange={onTextAreaChange}
188+
onClick={onTextAreaClick}
189+
onBlur={onTextAreaBlur}
190+
placeholder={textAreaPlaceholder}
191+
/>
192+
)}
193+
{isLoading && (
194+
<div className={styles.fileUploadFileDetailsSpinner}>
195+
<Spinner size={spinnerSize.lg} aria-valuetext={spinnerAriaValueText} />
196+
</div>
197+
)}
198+
</div>
199+
)}
198200
{children}
199201
</div>
200202
);

0 commit comments

Comments
 (0)