Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/input/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,13 +1285,14 @@ document.addEventListener("keydown", (event) => {
return;
}
if (isTypingTarget(event.target)) return;
// Backspace is what a Mac keyboard calls its Delete key.
// Backspace is what a Mac keyboard calls its Delete key. Not behind a dialog:
// the player can't see what it would remove.
if (
(event.key === "Delete" || event.key === "Backspace") &&
STATE.activeTool === "select" &&
STATE.isRunning &&
!window.tutorial?.isActive &&
document.getElementById("main-menu-modal").classList.contains("hidden")
!document.querySelector('[id$="-modal"]:not(.hidden)')
) {
[...STATE.selection].forEach(deleteObject);
STATE.selection.clear();
Expand Down
10 changes: 10 additions & 0 deletions tests/sim/multi-select.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ describe("Delete removes the selection", () => {
expect(STATE.services.length).toBe(3);
});

it.each(["share-modal", "faq-modal", "save-modal", "trophies-modal"])("not behind the %s", (id) => {
const dialog = document.getElementById(id);
dialog.classList.remove("hidden");

press("Delete");

dialog.classList.add("hidden");
expect(STATE.services.length).toBe(3);
});

it("not during the tutorial", () => {
window.tutorial.isActive = true;

Expand Down
Loading