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: Enhance keyboard handling in editable name cell component (#7818)

Myles Scolnickdd8501fa1eba
diff --git a/frontend/src/components/editor/actions/name-cell-input.tsx b/frontend/src/components/editor/actions/name-cell-input.tsx
index 47f7b98c8e..a5062bf7d6 100644
--- a/frontend/src/components/editor/actions/name-cell-input.tsx
+++ b/frontend/src/components/editor/actions/name-cell-input.tsx
@@ -93,11 +93,17 @@ export const NameCellContentEditable: React.FC<{
onChange={inputProps.onChange}
onBlur={inputProps.onBlur}
onFocus={inputProps.onFocus}
- onKeyDown={Events.onEnter((e) => {
- if (e.target instanceof HTMLElement) {
- e.target.blur();
+ onKeyDown={(e) => {
+ // Prevent all key presses from triggering hotkeys
+ e.stopPropagation();
+
+ // On Enter, blur the input to commit the change
+ if (e.key === "Enter") {
+ if (e.target instanceof HTMLElement) {
+ e.target.blur();
+ }
}
- })}
+ }}
>
{value}
</span>
diff --git a/frontend/src/utils/events.ts b/frontend/src/utils/events.ts
index f9541e1e88..3f68f0732b 100644
--- a/frontend/src/utils/events.ts
+++ b/frontend/src/utils/events.ts
@@ -42,6 +42,7 @@ export const Events = {
target.tagName === "INPUT" ||
target.tagName === "TEXTAREA" ||
target.tagName.startsWith("MARIMO") ||
+ target.isContentEditable ||
Events.fromCodeMirror(e)
);
},