Skip to content

Commit 5151a96

Browse files
authored
feat: updated useSectionCollapse methods (#4807)
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR fixes any issues, list them here by number (e.g., Fixes #123). --> Updated useSectionCollapse to use collapseAllCells and expandAllCells. Partially resolves #4163 by fixing useSectionCollapse bugs. ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> - Updates #4550 implementation by using expandAllCells and collapseAllCells rather than running expandCell and collapseCell in a loop - Fixes consecutive react renders issue - Fixes Node not in tree errors ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [x] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [x] I have added tests for the changes made. - [x] I have run the code and verified that it works as expected. ## 📜 Reviewers <!-- Tag potential reviewers from the community or maintainers who might be interested in reviewing this pull request. Your PR will be reviewed more quickly if you can figure out the right person to tag with @ --> @mscolnick
1 parent 4214d42 commit 5151a96

File tree

2 files changed

+4
-42
lines changed

2 files changed

+4
-42
lines changed

frontend/src/components/editor/actions/useNotebookActions.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ import { useRunAllCells } from "../cell/useRunCells";
8383
import { settingDialogAtom } from "@/components/app-config/state";
8484
import { AddDatabaseDialogContent } from "../database/add-database-form";
8585
import { useHideAllMarkdownCode } from "./useHideAllMarkdownCode";
86-
import { useSectionCollapse } from "./useSectionCollapse";
8786
import { Constants } from "@/core/constants";
8887

8988
const NOOP_HANDLER = (event?: Event) => {
@@ -99,13 +98,14 @@ export function useNotebookActions() {
9998
const [viewState] = useAtom(viewStateAtom);
10099
const kioskMode = useAtomValue(kioskModeAtom);
101100
const hideAllMarkdownCode = useHideAllMarkdownCode();
102-
const { collapseAllSections, expandAllSections } = useSectionCollapse();
103101

104102
const {
105103
updateCellConfig,
106104
undoDeleteCell,
107105
clearAllCellOutputs,
108106
upsertSetupCell,
107+
collapseAllCells,
108+
expandAllCells,
109109
} = useCellActions();
110110
const restartKernel = useRestartKernel();
111111
const runAllCells = useRunAllCells();
@@ -381,12 +381,12 @@ export function useNotebookActions() {
381381
{
382382
icon: <ChevronRightCircleIcon size={14} strokeWidth={1.5} />,
383383
label: "Collapse all sections",
384-
handle: collapseAllSections,
384+
handle: collapseAllCells,
385385
},
386386
{
387387
icon: <ChevronDownCircleIcon size={14} strokeWidth={1.5} />,
388388
label: "Expand all sections",
389-
handle: expandAllSections,
389+
handle: expandAllCells,
390390
},
391391
{
392392
icon: <DiamondPlusIcon size={14} strokeWidth={1.5} />,

frontend/src/components/editor/actions/useSectionCollapse.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)