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: dont open find/replace if another dialog is open (#67)

Myles Scolnick3ccfdc8e8f80
diff --git a/frontend/src/components/find-replace/find-replace.tsx b/frontend/src/components/find-replace/find-replace.tsx
index dc4bdfe1ee..091b5258a1 100644
--- a/frontend/src/components/find-replace/find-replace.tsx
+++ b/frontend/src/components/find-replace/find-replace.tsx
@@ -24,7 +24,7 @@ import {
XIcon,
} from "lucide-react";
import { useHotkey } from "@/hooks/useHotkey";
-import { EditorView } from "codemirror";
+import { EditorView } from "@codemirror/view";
import { FocusScope } from "@react-aria/focus";
import { toast } from "../ui/use-toast";
diff --git a/frontend/src/core/codemirror/find-replace/navigate.ts b/frontend/src/core/codemirror/find-replace/navigate.ts
index 0f594be347..4656276bf9 100644
--- a/frontend/src/core/codemirror/find-replace/navigate.ts
+++ b/frontend/src/core/codemirror/find-replace/navigate.ts
@@ -2,7 +2,7 @@
import { store } from "@/core/state/jotai";
import { SearchCursor, SearchQuery } from "@codemirror/search";
import { EditorSelection, EditorState } from "@codemirror/state";
-import { EditorView } from "codemirror";
+import { EditorView } from "@codemirror/view";
import { findReplaceAtom } from "./state";
import { getAllEditorViews } from "@/core/state/cells";
diff --git a/frontend/src/core/codemirror/find-replace/state.ts b/frontend/src/core/codemirror/find-replace/state.ts
index 7cc3d084f2..b61070e080 100644
--- a/frontend/src/core/codemirror/find-replace/state.ts
+++ b/frontend/src/core/codemirror/find-replace/state.ts
@@ -1,6 +1,6 @@
/* Copyright 2023 Marimo. All rights reserved. */
import { store } from "@/core/state/jotai";
-import { EditorView } from "codemirror";
+import { EditorView } from "@codemirror/view";
import { atomWithReducer } from "jotai/utils";
interface FindReplaceState {
@@ -90,6 +90,13 @@ export const findReplaceAtom = atomWithReducer<FindReplaceState, Action>(
);
export function openFindReplacePanel(initialView?: EditorView): boolean {
+ // If any radix dialog is open, don't open the find/replace panel
+ // they have role="dialog" and data-state="open"
+ const element = document.querySelector('[role="dialog"][data-state="open"]');
+ if (element) {
+ return false;
+ }
+
if (initialView) {
// Set the selected text and focus
const selection = initialView.state.selection.main;
diff --git a/frontend/src/core/codemirror/format.ts b/frontend/src/core/codemirror/format.ts
index 68e7fc14ee..304cd6772b 100644
--- a/frontend/src/core/codemirror/format.ts
+++ b/frontend/src/core/codemirror/format.ts
@@ -1,5 +1,5 @@
/* Copyright 2023 Marimo. All rights reserved. */
-import { EditorView } from "codemirror";
+import { EditorView } from "@codemirror/view";
import { CellId } from "../model/ids";
import { Objects } from "../../utils/objects";
import { sendFormat } from "../network/requests";
diff --git a/frontend/src/editor/renderers/CellArray.tsx b/frontend/src/editor/renderers/CellArray.tsx
index 614cee197a..733fb99b30 100644
--- a/frontend/src/editor/renderers/CellArray.tsx
+++ b/frontend/src/editor/renderers/CellArray.tsx
@@ -1,5 +1,5 @@
/* Copyright 2023 Marimo. All rights reserved. */
-import { EditorView } from "codemirror";
+import { EditorView } from "@codemirror/view";
import { useEffect, useState } from "react";
import { sendDeleteCell } from "@/core/network/requests";
import { Cell } from "editor/Cell";