Skip to content

Commit a830bf8

Browse files
authored
Fix: Drag and Drop not working due an Electron breaking change
1 parent 3d51f9e commit a830bf8

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
##### 🐛 Bug Fixes
1010

1111
- Error saving images with dialog [`f2445de`](https://github.com/ollm/OpenComic/commit/f2445de4af8e515fe9dda2ed7dc71e3213922b8e)
12+
- Drag and Drop not working due an Electron breaking change
1213

1314
## [v1.4.0](https://github.com/ollm/OpenComic/releases/tag/v1.4.0) (26-01-2025)
1415

scripts/drag-and-drop.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,22 @@ function handleDrop(event)
7575
{
7676
event.preventDefault();
7777

78-
if(dragAndDropFocus && event.dataTransfer.files && event.dataTransfer.files[0] && event.dataTransfer.files[0].path)
78+
const firstPath = event.dataTransfer?.files?.[0] ? electron.webUtils.getPathForFile(event.dataTransfer.files[0]) : false;
79+
80+
if(dragAndDropFocus && firstPath)
7981
{
80-
let type = dragAndDropFocus.dataset.type;
82+
const type = dragAndDropFocus.dataset.type;
8183

82-
if(pathIsSupported(event.dataTransfer.files[0].path))
84+
if(pathIsSupported(firstPath))
8385
{
84-
let files = [];
86+
const files = [];
8587

8688
for(let i = 0, len = event.dataTransfer.files.length; i < len; i++)
8789
{
88-
if(pathIsSupported(event.dataTransfer.files[i].path))
89-
files.push(event.dataTransfer.files[i].path);
90+
const path = electron.webUtils.getPathForFile(event.dataTransfer.files[i]);
91+
92+
if(pathIsSupported(path))
93+
files.push(path);
9094
}
9195

9296
if(type == 'add')

0 commit comments

Comments
 (0)