Skip to content

Commit

Permalink
#59 clear input field before opening fileselection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Preisig committed Nov 29, 2023
1 parent e51dbe4 commit 3aa32f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/material/ImportAddMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export const ImportAddMaterialButton = (props: importAddMaterialProps) => {
const [updateLoading] = useState(false);
let excelInput = React.useRef<HTMLInputElement>(null);

function clearFileInput() {
if (excelInput.current?.value) {
excelInput.current.value = '';
}
}

return <>
<input
style={{ display: 'none' }}
Expand All @@ -33,6 +39,7 @@ export const ImportAddMaterialButton = (props: importAddMaterialProps) => {
message.error('Leider ist ein Fehler beim lesen der Datei aufgetreten 2');
}
}}
onClick={clearFileInput}
/>
<Button type='primary' disabled={updateLoading} onClick={() => excelInput?.current?.click()}>
Excel Import
Expand Down

0 comments on commit 3aa32f5

Please sign in to comment.