Skip to content

Commit

Permalink
Fixes browser upload input issue (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdavella authored Apr 28, 2024
1 parent 3cc72fa commit ef61d9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/src/components/settings/ImageUploadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import InputAdornment from '@mui/material/InputAdornment';
import InputLabel from '@mui/material/InputLabel';
import OutlinedInput, { OutlinedInputProps } from '@mui/material/OutlinedInput';
import { styled } from '@mui/material/styles';
import React, { ChangeEvent, useCallback } from 'react';
import React, { ChangeEvent, useCallback, useRef } from 'react';
import { useTunarrApi } from '../../hooks/useTunarrApi';

const VisuallyHiddenInput = styled('input')({
Expand Down Expand Up @@ -41,6 +41,7 @@ export function ImageUploadInput({
value,
children,
}: Props) {
const fileInputRef = useRef<HTMLInputElement>(null);
const apiClient = useTunarrApi();
const handleFileUpload = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -89,8 +90,9 @@ export function ImageUploadInput({
endAdornment={
<InputAdornment position="end">
<IconButton component="label">
<CloudUpload />
<CloudUpload onClick={() => (fileInputRef.current!.value = '')} />
<VisuallyHiddenInput
ref={fileInputRef}
onChange={(e) => {
handleFileUpload(e);
}}
Expand Down

0 comments on commit ef61d9a

Please sign in to comment.