diff --git a/src/components/file-preview/file-preview.stories.tsx b/src/components/file-preview/file-preview.stories.tsx index d7901548..e1e022b2 100644 --- a/src/components/file-preview/file-preview.stories.tsx +++ b/src/components/file-preview/file-preview.stories.tsx @@ -1,7 +1,7 @@ import { Meta, StoryFn } from '@storybook/react'; import { FilePreview, FilePreviewFile, FilePreviewProps } from './file-preview'; import { Input } from '@/index'; -import { useState } from 'react'; +import { useRef, useState } from 'react'; type InputValue = string | FileList | null; @@ -65,6 +65,7 @@ DisabledState.args = { }; export const FileInputWithPreview: Story = ( args ) => { + const fileInputRef = useRef( null ); const [ selectedFile, setSelectedFile ] = useState( null ); const handleFileChange = ( value: InputValue ) => { @@ -85,6 +86,7 @@ export const FileInputWithPreview: Story = ( args ) => { return ( <> { setSelectedFile( null ) } + onRemove={ () => { + setSelectedFile( null ); + if ( fileInputRef.current ) { + fileInputRef.current.value = ''; + } + } } /> ) }