Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Dec 12, 2025

Fixes #7487

It may not (or ever) feel perfect; layout shifts will be inevitable. But this does return the focus to the selected line or button or editor after closing a temporarily shown cell (temporarily shown --> marked hidden, but was focused)

@vercel
Copy link

vercel bot commented Dec 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Dec 15, 2025 9:06pm

* First tries to scroll the active line into view, if the cell is focused.
* If not, it scrolls the cell container into view.
*/
export function scrollCellIntoView(cellId: CellId): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a file called scrollCellIntoView.ts. Should this live there and/or renamed?

const restoreFocus = useRestoreFocus();

useEffect(() => {
if (open) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any thoughts on this lint comment? I think we could make a handleOpen function and call this wherener setOpen()

Copy link
Contributor

@Light2Dark Light2Dark Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, the lint comment is Avoid using state and effects as an event handler. Instead, call the event handling code directly when the event occurs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i can make a handleOpen callback

@mscolnick mscolnick merged commit 9afb928 into main Dec 15, 2025
26 checks passed
@mscolnick mscolnick deleted the ms/focus-scroll branch December 15, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long hidden cells cause visual jumps when collapsed

3 participants