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: elminate bouncing of tooltip near end of editor (#379)

Akshay Agrawal429ec611dc9b
diff --git a/frontend/src/components/editor/Cell.tsx b/frontend/src/components/editor/Cell.tsx
index 8f1199e963..7e1cb45e17 100644
--- a/frontend/src/components/editor/Cell.tsx
+++ b/frontend/src/components/editor/Cell.tsx
@@ -17,7 +17,7 @@ import {
import { sendRun } from "@/core/network/requests";
import { autocompletionKeymap, setupCodeMirror } from "@/core/codemirror/cm";
-
+import { clearTooltips } from "@/core/codemirror/completion/hints";
import { UserConfig } from "../../core/config/config-schema";
import { CellData, CellRuntimeState } from "../../core/cells/types";
import { CellActions, useCellActions } from "../../core/cells/cells";
@@ -357,6 +357,7 @@ const CellComponent = (
editorView.current !== null
) {
closeCompletion(editorView.current);
+ clearTooltips(editorView.current);
}
}, []);
diff --git a/frontend/src/core/codemirror/cm.ts b/frontend/src/core/codemirror/cm.ts
index 29f603d364..d8b4c422d5 100644
--- a/frontend/src/core/codemirror/cm.ts
+++ b/frontend/src/core/codemirror/cm.ts
@@ -128,8 +128,9 @@ export const basicBundle = (
lineNumbers(),
rectangularSelection(),
tooltips({
- // Having absolute position makes it possible to select text in the tooltip
- position: "absolute",
+ // Having fixed position prevents tooltips from being repositioned
+ // and bouncing distractingly
+ position: "fixed",
}),
scrollActiveLineIntoView(),
theme === "dark" ? oneDark : [],
diff --git a/frontend/src/core/codemirror/completion/hints.ts b/frontend/src/core/codemirror/completion/hints.ts
index b2915a5046..d5e177754e 100644
--- a/frontend/src/core/codemirror/completion/hints.ts
+++ b/frontend/src/core/codemirror/completion/hints.ts
@@ -70,15 +70,8 @@ export function hintTooltip() {
},
])
),
- // Clear tooltips on blur
- EditorView.domEventObservers({
- blur: (event, view) => {
- // Only close tooltip, not view; blur for completion handled by
- // cell editor, so that completion text is selectable
- // TODO: make text in cursor tooltips selectable
- clearTooltips(view);
- },
- }),
+ // Removing tooltips (and completion) on blur is handled by cell editor, so
+ // that text is selectable
];
}
diff --git a/frontend/src/css/codemirror.css b/frontend/src/css/codemirror.css
index 78190e4598..60fc7f0550 100644
--- a/frontend/src/css/codemirror.css
+++ b/frontend/src/css/codemirror.css
@@ -42,7 +42,7 @@
#App .cm-tooltip.mo-cm-tooltip,
#App .cm-tooltip.cm-completionInfo {
max-height: 45vh; /* 45% of viewport height */
- max-width: 80vw; /* 80% of viewport width */
+ max-width: 40vw; /* 40% of viewport width */
overflow: auto;
/* Respect newlines. */