Skip to content

Commit

Permalink
Merge pull request #447 from NordicSemiconductor/fix/file-drag
Browse files Browse the repository at this point in the history
fix: don't open file in editor when drag and drop
  • Loading branch information
boundlesscalm authored Feb 28, 2024
2 parents ab86983 + 9643f7c commit 6e82b64
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 6e82b64

Please sign in to comment.