Skip to content

fix: stop reversing in place in SheetManager.get#507

Open
luka-archon wants to merge 1 commit into
ammarahm-ed:masterfrom
luka-archon:master
Open

fix: stop reversing in place in SheetManager.get#507
luka-archon wants to merge 1 commit into
ammarahm-ed:masterfrom
luka-archon:master

Conversation

@luka-archon

Copy link
Copy Markdown

Issue

I'm running into a bug with nested sheets where i'm having sheets disappear from renderedSheetIds. Example flow:

  1. Open parent sheet A
  2. Open child sheet B
  3. Close child B
  4. Open another child C
  5. Try to hide/close both child sheet C and parent sheet A. Only sheet C closes, and parent sheet A stays open.

When I check getActiveSheets after closing child sheet (B), it doesn't contain the parent sheet (A) anymore.

Root cause

When calling SheetManager.get(sheetId) without a context, the library iterates through renderedSheetIds using renderedSheetIds.reverse(). This mutates the array in place, which messes up the ordering of renderedSheetIds.

Then if we call SheetManager.remove() it removes all ids starting from the passed in id to the end of the array. Since we reversed the renderedSheetIds in place, it was probably removing the sheets that were still open when we close a sheet, due to the array order.

Fix

In SheetManager.get() instead of iterating renderedSheetIds.reverse() in place, iterate over a copy: renderedSheetIds.slice().reverse()

@vercel

vercel Bot commented Feb 9, 2026

Copy link
Copy Markdown

@luka-archon is attempting to deploy a commit to the Ammar Ahmed's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant