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 #1751: file_browser won't navigate to non-existant paths when clicking fast (#1879)

H. Eugene637440477d35
diff --git a/docs/guides/hotkeys.md b/docs/guides/hotkeys.md
index b120bad83f..cd7c2a1ddb 100644
--- a/docs/guides/hotkeys.md
+++ b/docs/guides/hotkeys.md
@@ -4,53 +4,53 @@ If you'd like to override the default hotkeys, you can do so in the hotkeys menu
You can find a list of available hotkeys below:
-| Hotkey |
-|---------------------------|
-| `cell.aiCompletion` |
-| `cell.cellActions` |
-| `cell.complete` |
-| `cell.createAbove` |
-| `cell.createBelow` |
-| `cell.delete` |
-| `cell.findAndReplace` |
-| `cell.focusDown` |
-| `cell.focusUp` |
-| `cell.fold` |
-| `cell.foldAll` |
-| `cell.format` |
-| `cell.goToDefinition` |
-| `cell.hideCode` |
-| `cell.moveDown` |
-| `cell.moveUp` |
-| `cell.redo` |
-| `cell.run` |
-| `cell.runAndNewAbove` |
-| `cell.runAndNewBelow` |
+| Hotkey |
+| --------------------------- |
+| `cell.aiCompletion` |
+| `cell.cellActions` |
+| `cell.complete` |
+| `cell.createAbove` |
+| `cell.createBelow` |
+| `cell.delete` |
+| `cell.findAndReplace` |
+| `cell.focusDown` |
+| `cell.focusUp` |
+| `cell.fold` |
+| `cell.foldAll` |
+| `cell.format` |
+| `cell.goToDefinition` |
+| `cell.hideCode` |
+| `cell.moveDown` |
+| `cell.moveUp` |
+| `cell.redo` |
+| `cell.run` |
+| `cell.runAndNewAbove` |
+| `cell.runAndNewBelow` |
| `cell.selectNextOccurrence` |
-| `cell.sendToBottom` |
-| `cell.sendToTop` |
-| `cell.splitCell` |
-| `cell.undo` |
-| `cell.unfold` |
-| `cell.unfoldAll` |
-| `cell.viewAsMarkdown` |
-| `global.commandPalette` |
-| `global.focusBottom` |
-| `global.focusTop` |
-| `global.foldCode` |
-| `global.formatAll` |
-| `global.hideCode` |
-| `global.interrupt` |
-| `global.runStale` |
-| `global.save` |
-| `global.showHelp` |
-| `global.toggleLanguage` |
-| `global.toggleSidebar` |
-| `global.unfoldCode` |
-| `markdown.blockquote` |
-| `markdown.bold` |
-| `markdown.code` |
-| `markdown.italic` |
-| `markdown.link` |
-| `markdown.orderedList` |
-| `markdown.unorderedList` |
+| `cell.sendToBottom` |
+| `cell.sendToTop` |
+| `cell.splitCell` |
+| `cell.undo` |
+| `cell.unfold` |
+| `cell.unfoldAll` |
+| `cell.viewAsMarkdown` |
+| `global.commandPalette` |
+| `global.focusBottom` |
+| `global.focusTop` |
+| `global.foldCode` |
+| `global.formatAll` |
+| `global.hideCode` |
+| `global.interrupt` |
+| `global.runStale` |
+| `global.save` |
+| `global.showHelp` |
+| `global.toggleLanguage` |
+| `global.toggleSidebar` |
+| `global.unfoldCode` |
+| `markdown.blockquote` |
+| `markdown.bold` |
+| `markdown.code` |
+| `markdown.italic` |
+| `markdown.link` |
+| `markdown.orderedList` |
+| `markdown.unorderedList` |
diff --git a/frontend/src/plugins/impl/FileBrowserPlugin.tsx b/frontend/src/plugins/impl/FileBrowserPlugin.tsx
index 75c783e743..50ea363d5d 100644
--- a/frontend/src/plugins/impl/FileBrowserPlugin.tsx
+++ b/frontend/src/plugins/impl/FileBrowserPlugin.tsx
@@ -135,6 +135,7 @@ export const FileBrowser = ({
}: FileBrowserProps): JSX.Element | null => {
const [path, setPath] = useState(initialPath);
const [selectAllLabel, setSelectAllLabel] = useState("Select all");
+ const [isUpdatingPath, setIsUpdatingPath] = useState(false);
const { data, loading, error } = useAsyncData(
() =>
@@ -173,9 +174,17 @@ export const FileBrowser = ({
const canSelectFiles = selectionMode === "file" || selectionMode === "all";
function setNewPath(newPath: string) {
+ // Prevent updating path while updating
+ if (isUpdatingPath) {
+ return;
+ }
+ // Set updating flag
+ setIsUpdatingPath(true);
+
// Navigate to parent directory
if (newPath === PARENT_DIRECTORY) {
if (path === delimiter) {
+ setIsUpdatingPath(false);
return;
}
@@ -196,11 +205,14 @@ export const FileBrowser = ({
"Access to directories outside initial path is restricted.",
variant: "danger",
});
+ setIsUpdatingPath(false);
return;
}
+ // Update path and reset select all label
setPath(newPath);
setSelectAllLabel("Select all");
+ setIsUpdatingPath(false);
}
function createFileInfo(