Skip to content

Commit

Permalink
fix: don't open file in editor when drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Pickel authored and Pascal Pickel committed Feb 28, 2024
1 parent ab86983 commit 9643f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- Valid Modem Firmware for Thingy:91 was previously detected as incorrect.
- Show the device family in the Memory layout title for MCUboot devices.
- Windows and Linux: Dragging and dropping a file into the file memory layout
opened the file in an editor.

### Removed

Expand Down
5 changes: 3 additions & 2 deletions src/components/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const useRegisterDragEvents = () => {
const onDrop = async (event: DragEvent) => {
if (!event.dataTransfer) return;

// calling this after our code would result in opening the file in an editor (atleast this was the case on linux)
event.preventDefault();

// eslint-disable-next-line no-restricted-syntax
for (const file of event.dataTransfer.files) {
// eslint-disable-next-line no-await-in-loop
Expand All @@ -60,8 +63,6 @@ const useRegisterDragEvents = () => {
)
);
}

event.preventDefault();
};

document.body.addEventListener('drop', onDrop);
Expand Down

0 comments on commit 9643f7c

Please sign in to comment.