pl-fe: do not specify 'accept' when set to 'application/octet-stream'
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
6a31cd2c61
commit
9096fdc9fb
2 changed files with 10 additions and 2 deletions
|
@ -37,6 +37,9 @@ const UploadButton: React.FC<IUploadButton> = ({
|
|||
const fileElement = useRef<HTMLInputElement>(null);
|
||||
const attachmentTypes = configuration.media_attachments.supported_mime_types;
|
||||
|
||||
let accept = attachmentTypes?.join(',');
|
||||
if (accept === 'application/octet-stream') accept = undefined;
|
||||
|
||||
const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
if (e.target.files?.length) {
|
||||
onSelectFile(e.target.files, intl);
|
||||
|
@ -75,7 +78,7 @@ const UploadButton: React.FC<IUploadButton> = ({
|
|||
ref={fileElement}
|
||||
type='file'
|
||||
multiple
|
||||
accept={attachmentTypes?.join(',')}
|
||||
accept={accept}
|
||||
onChange={handleChange}
|
||||
disabled={disabled}
|
||||
className='hidden'
|
||||
|
|
|
@ -12,9 +12,13 @@ interface IUploadButton {
|
|||
|
||||
const UploadButton: React.FC<IUploadButton> = ({ disabled, onSelectFile }) => {
|
||||
const fileElement = useRef<HTMLInputElement>(null);
|
||||
|
||||
const attachmentTypes = useAppSelector(state => state.instance.configuration.media_attachments.supported_mime_types)
|
||||
?.filter((type) => type.startsWith('image/'));
|
||||
|
||||
let accept = attachmentTypes?.join(',');
|
||||
if (accept === 'application/octet-stream') accept = undefined;
|
||||
|
||||
const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
if (e.target.files?.length) {
|
||||
onSelectFile(e.target.files);
|
||||
|
@ -25,6 +29,7 @@ const UploadButton: React.FC<IUploadButton> = ({ disabled, onSelectFile }) => {
|
|||
fileElement.current?.click();
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<HStack className='h-full w-full cursor-pointer text-primary-500 dark:text-accent-blue' space={3} alignItems='center' justifyContent='center' element='label'>
|
||||
<Icon
|
||||
|
@ -39,7 +44,7 @@ const UploadButton: React.FC<IUploadButton> = ({ disabled, onSelectFile }) => {
|
|||
<input
|
||||
ref={fileElement}
|
||||
type='file'
|
||||
accept={attachmentTypes?.join(',')}
|
||||
accept={accept}
|
||||
onChange={handleChange}
|
||||
disabled={disabled}
|
||||
className='hidden'
|
||||
|
|
Loading…
Reference in a new issue