mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
26.79k stars 1.9k forks source link

File Type Mismatch for .xlsm Files with useFsAccessApi Enabled in Mantine Dropzone #7075

Closed ajai-am closed 1 week ago

ajai-am commented 1 week ago

Dependencies check up

What version of @mantine/* packages do you have in package.json?

7.12.2

What package has an issue?

@mantine/dropzone

What framework do you use?

create-react-app (CRA)

In which browsers you can reproduce the issue?

All

Describe the bug

Description:

When using the Dropzone component from Mantine with .xlsm files, there is an inconsistency in file type detection depending on the file selection method.

  1. Drag and Drop: When I drag and drop a .xlsm file, the onDrop callback correctly identifies the MIME type as application/vnd.ms-excel.sheet.macroenabled.12.

Screenshot 2024-11-05 at 10 00 38 AM

  1. File Selection with useFsAccessApi: If I use the file selection dialog with useFsAccessApi enabled (set to true), the MIME type in the onDrop callback is an empty string. Consequently, the browser defaults to application/octet-stream when sending the file to the backend, causing issues with correct file type handling.

Screenshot 2024-11-05 at 10 00 01 AM

Expected Behavior:

When selecting .xlsm files through the file selection dialog with useFsAccessApi enabled, the MIME type should be detected as application/vnd.ms-excel.sheet.macroenabled.12, consistent with the drag-and-drop method.

Steps to Reproduce:

  1. Use Mantine's Dropzone component with useFsAccessApi enabled.
  2. Attempt to upload a .xlsm file using both drag-and-drop and file selection.
  3. Observe the MIME type returned in the onDrop callback.

This discrepancy impacts handling of .xlsm files in applications that rely on correct MIME type detection.

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

No response

Self-service

rtivital commented 1 week ago

This logic is handled in react-dropzone library, you are report the issue in their repository. Currently the issue cannot be fixed on Mantine side.

ajai-am commented 1 week ago

Hi @rtivital I tried using react-dropzone v14.2.9, there, this bug doesn't occur, probably they had this bug & got if fixed down the line it seems.

I came across this url https://codesandbox.io/p/devbox/currying-thunder-jq6d5, when i tried I got the expected result.

As I can see from the forked repo of yours https://github.com/rtivital/react-dropzone-esm it was lasted updated on 2023, could it be that this fix was not added into your forked version?

Since the mantine dropzone, directly depends on react-dropzone-esm & not react-dropzone, hence raising this request.

rtivital commented 1 week ago

Okay, I'll update react-dropzone-esm to the latest react-dropzone changes in one of the next patches

ajai-am commented 1 week ago

Thank you