Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: honor preventDefault in editor hotkeys (#7394)

Myles Scolnick9c53e8ba56d3
diff --git a/frontend/src/hooks/useHotkey.ts b/frontend/src/hooks/useHotkey.ts
index 1ca3848ed5..7855d756e0 100644
--- a/frontend/src/hooks/useHotkey.ts
+++ b/frontend/src/hooks/useHotkey.ts
@@ -31,6 +31,10 @@ export function useHotkey(shortcut: HotkeyAction, callback: HotkeyHandler) {
const memoizeCallback = useEvent((evt?: KeyboardEvent) => callback(evt));
const listener = useEvent((e: KeyboardEvent) => {
+ if (e.defaultPrevented) {
+ return;
+ }
+
const key = hotkeys.getHotkey(shortcut).key;
if (parseShortcut(key)(e)) {
const response = callback(e);
@@ -62,6 +66,10 @@ export function useKeydownOnElement(
handlers: Record<string, HotkeyHandler>,
) {
useEventListener(element, "keydown", (e) => {
+ if (e.defaultPrevented) {
+ return;
+ }
+
for (const [key, callback] of Objects.entries(handlers)) {
if (parseShortcut(key)(e)) {
Logger.debug("Satisfied", key, e);