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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: focus top and focus bottom (#1734)
Myles Scolnick3ef20b7225db
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.tsindex bc4b935cff..9d17203474 100644--- a/frontend/src/core/cells/cells.ts+++ b/frontend/src/core/cells/cells.ts@@ -37,7 +37,11 @@ import {updateEditorCodeFromPython,} from "../codemirror/language/utils";import { invariant } from "@/utils/invariant";-import { CellConfig, CellStatus, UpdateCellIdsRequest } from "../network/types";+import type {+ CellConfig,+ CellStatus,+ UpdateCellIdsRequest,+} from "../network/types";import { getUserConfig } from "@/core/config/config";import { syncCellIds } from "../network/requests";import { kioskModeAtom } from "../mode";@@ -279,7 +283,11 @@ const {}const cellKey = state.cellIds[0];- state.cellHandles[cellKey].current?.editorView.focus();+ const cellData = state.cellData[cellKey];+ const cellHandle = state.cellHandles[cellKey];+ if (!cellData.config.hide_code) {+ cellHandle.current?.editorView.focus();+ }scrollToTop();return state;},@@ -289,7 +297,11 @@ const {}const cellKey = state.cellIds[state.cellIds.length - 1];- state.cellHandles[cellKey].current?.editorView.focus();+ const cellData = state.cellData[cellKey];+ const cellHandle = state.cellHandles[cellKey];+ if (!cellData.config.hide_code) {+ cellHandle.current?.editorView.focus();+ }scrollToBottom();return state;},diff --git a/frontend/src/core/cells/scrollCellIntoView.ts b/frontend/src/core/cells/scrollCellIntoView.tsindex f6a989d4d1..b9153487e2 100644--- a/frontend/src/core/cells/scrollCellIntoView.ts+++ b/frontend/src/core/cells/scrollCellIntoView.ts@@ -4,7 +4,7 @@ import { Logger } from "../../utils/Logger";import { type CellId, HTMLCellId } from "./ids";import type { CellHandle } from "@/components/editor/Cell";import { goToVariableDefinition } from "../codemirror/go-to-definition/commands";-import { CellConfig } from "../network/types";+import type { CellConfig } from "../network/types";export function focusAndScrollCellIntoView({cellId,@@ -93,9 +93,11 @@ export function focusAndScrollCellOutputIntoView(cellId: CellId) {* manually to the bottom/top is reliable.*/export function scrollToBottom() {- window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });+ const app = document.getElementById("App");+ app?.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });}export function scrollToTop() {- window.scrollTo({ top: 0, behavior: "smooth" });+ const app = document.getElementById("App");+ app?.scrollTo({ top: 0, behavior: "smooth" });}