edrlab / thorium-reader

A cross platform desktop reading app, based on the Readium Desktop toolkit
https://www.edrlab.org/software/thorium-reader/
BSD 3-Clause "New" or "Revised" License
1.86k stars 157 forks source link

calling MacOS developers / users, please test EPUB drag+drop on library window to import publication #2647

Closed danielweck closed 1 week ago

danielweck commented 1 week ago

...this is broken on my Mac (running from the develop branch, I tried Electron versions 30...33 so this must be a regression in MacOS Sequoia 15.1)

I filed a bug report but I need a repro test case:

https://github.com/electron/electron/issues/44600

NOTE: the <input type="file"> still works, the breaking change is only for drag-drop event.

danielweck commented 1 week ago

Ah, I am unable to reproduce with ElectronFiddle, so the regression bug must have arisen from somewhere else!

To test, I added the following event handlers in ElectronFiddle's DOMContentLoaded template:

document.getElementsByTagName("body")[0].addEventListener("dragover", (event) => {
  event.preventDefault();
});
document.getElementsByTagName("body")[0].addEventListener("drop", (ev) => {
  ev.preventDefault();
    console.log(ev.dataTransfer.files[0].name);
    console.log(ev.dataTransfer.files[0].path);
    console.log(require("electron").webUtils.getPathForFile(ev.dataTransfer.files[0]));
});
danielweck commented 1 week ago

We're using https://www.npmjs.com/package/react-dropzone The fix was to pass thegetFilesFromEvent prop to the <DropZone> component and to simply return Array.from(ev.dataTransfer.files) ... go figure :)

https://github.com/react-dropzone/react-dropzone/blob/4ca683b9ed7a703661c5eacd0f6ef5e9b90e317f/typings/tests/plugin.tsx#L5-L8

danielweck commented 1 week ago

Fixed via https://github.com/edrlab/thorium-reader/commit/941fb36c30974b43eee1493aed326f0c49d26acf