Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix(common): drop ctrl+backspace, ctrl+delete (#6541)

Shreyas4df92e93438d
diff --git a/packages/hoppscotch-common/src/helpers/__tests__/keybindings.spec.ts b/packages/hoppscotch-common/src/helpers/__tests__/keybindings.spec.ts
index 7b02e4bfd..1112594c6 100644
--- a/packages/hoppscotch-common/src/helpers/__tests__/keybindings.spec.ts
+++ b/packages/hoppscotch-common/src/helpers/__tests__/keybindings.spec.ts
@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest"
-import { resolvePressedKey } from "../keybindings"
+import { bindings, resolvePressedKey } from "../keybindings"
// Fixture builder to keep individual cases readable. Layout name in the
// describe block is the conceptual layout; `key` and `code` are what the
@@ -196,3 +196,26 @@ describe("resolvePressedKey: edge cases", () => {
).toBeNull()
})
})
+
+describe("bindings: native word-delete chords stay unmapped", () => {
+ // ctrl-backspace and ctrl-delete are the browser's word-delete chords in
+ // any editable input (URL bar, header value, body). Mapping either to
+ // response.erase wiped the response pane while the user was only deleting
+ // a word (hoppscotch/hoppscotch#5967). handleKeyDown lets the native chord
+ // through only while it stays unmapped, so a future shortcut addition that
+ // rebinds either one would silently bring the bug back. These assertions
+ // are the guard against that.
+ const chords = Object.keys(bindings)
+
+ test("ctrl-backspace has no action", () => {
+ expect(chords).not.toContain("ctrl-backspace")
+ })
+
+ test("ctrl-delete has no action", () => {
+ expect(chords).not.toContain("ctrl-delete")
+ })
+
+ test("no chord maps to response.erase", () => {
+ expect(Object.values(bindings)).not.toContain("response.erase")
+ })
+})
diff --git a/packages/hoppscotch-common/src/helpers/keybindings.ts b/packages/hoppscotch-common/src/helpers/keybindings.ts
index 6dd00ec1a..e0124f2cd 100644
--- a/packages/hoppscotch-common/src/helpers/keybindings.ts
+++ b/packages/hoppscotch-common/src/helpers/keybindings.ts
@@ -91,8 +91,6 @@ const baseBindings: {
"ctrl-shift-l": "editor.format",
"ctrl-z": "editor.undo",
"ctrl-y": "editor.redo",
- "ctrl-delete": "response.erase",
- "ctrl-backspace": "response.erase",
}
// Web-only bindings