1414 * limitations under the License.
1515 */
1616
17- import { ChangeEvent } from 'react'
17+ import { ChangeEvent , useMemo } from 'react'
1818
19- import { ReactComponent as ICUploadArrowAnimated } from '@Icons/ic-upload-arrow-animated.svg'
20- import { ReactComponent as ICFileText } from '@Icons/ic-file-text.svg'
2119import { ReactComponent as ICCross } from '@Icons/ic-cross.svg'
20+ import { ReactComponent as ICFileText } from '@Icons/ic-file-text.svg'
21+ import { ReactComponent as ICUploadArrowAnimated } from '@Icons/ic-upload-arrow-animated.svg'
2222import { Tooltip } from '@Common/Tooltip'
23-
2423import { ComponentSizeType } from '@Shared/constants'
24+ import { getUniqueId } from '@Shared/Helpers'
2525
2626import { Button , ButtonStyleType , ButtonVariantType } from '../Button'
2727import { FileUploadProps } from './types'
@@ -36,6 +36,8 @@ export const FileUpload = ({
3636 fileTypes = [ ] ,
3737 onUpload,
3838} : FileUploadProps ) => {
39+ const id = useMemo ( ( ) => `fileInput-${ getUniqueId ( ) } ` , [ ] )
40+
3941 // METHODS
4042 const handleFileChange = ( event : ChangeEvent < HTMLInputElement > ) => {
4143 if ( event . target . files ) {
@@ -88,11 +90,11 @@ export const FileUpload = ({
8890 ) : (
8991 < div className = "dc__position-rel flex" >
9092 { /* eslint-disable-next-line jsx-a11y/label-has-associated-control */ }
91- < label htmlFor = "fileInput" className = "m-0 fw-4 cb-5 fs-13 lh-20 flex-grow-1 cursor" >
93+ < label htmlFor = { id } className = "m-0 fw-4 cb-5 fs-13 lh-20 flex-grow-1 cursor" >
9294 { label || 'Upload file…' }
9395 </ label >
9496 < input
95- id = "fileInput"
97+ id = { id }
9698 type = "file"
9799 className = "dc__visibility-hidden dc__position-abs dc__top-0 dc__right-0 dc__bottom-0 dc__left-0"
98100 onChange = { handleFileChange }
0 commit comments