Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Fix files drop event opening a new window #45

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ts/grid/events/GridEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ class GridEvents extends EventTarget {

if (notSuccesful) return;

e.preventDefault();
e.stopPropagation();

let $button = getTarget(e);

$button.trigger("dragleave");

e.preventDefault();
e.stopPropagation();

$button.removeClass("file-dragover");

const file = e.originalEvent.dataTransfer.files[0];
Expand Down
5 changes: 5 additions & 0 deletions src/ts/start/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ abstract class Main {
} else {
throw new TypeError("JQueryFixes is not available");
}

// This prevents a new window from opening when a file is randomly dropped on the page
$(document).on("drop", (e) => {
e.preventDefault();
});

if (appPathRequest) {
await appPathRequest;
Expand Down
3 changes: 2 additions & 1 deletion src/ts/start/MainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ abstract class MainWindow extends Main {

// Setup context menu
// TODO: class?
$(document).on("contextmenu", () => {
$(document).on("contextmenu", (e) => {
e.preventDefault();
SoundboardApi.mainWindow.openContextMenu();
});

Expand Down