Skip to content

fix(ui): preserve refs across hidden subtrees - #2684

Closed
stipsan wants to merge 4 commits into
mainfrom
cursor/fix-suspense-ref-cycles-5bf7
Closed

stipsan wants to merge 4 commits into
mainfrom
cursor/fix-suspense-ref-cycles-5bf7

Conversation

@stipsan

@stipsan stipsan commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • add an internal connected-element ref helper that suppresses transient React Suspense and Activity detach callbacks while preserving real removal cleanup
  • apply it to Tooltip, Popover, Menu, TreeItem, Autocomplete, and ElementQuery ref state
  • guard the docs Arcade iframe root from transient null refs
  • add Activity, Suspense, real-removal, and Menu registration regression coverage
  • add a patch changeset for @sanity/ui

Testing

  • pnpm --filter @sanity/ui exec vitest run src/core/hooks/useConnectedRef.test.tsx src/core/components/menu/menu.test.tsx (7 passed)
  • pnpm test (641 passed across color, icons, UI, and themer)
  • pnpm lint
  • pnpm --filter sanity-ui-docs typecheck
  • pnpm --filter @sanity/ui build
  • pnpm knip
  • pnpm test:browser (61 files, 245 tests passed in Chromium; browser installed with the repository-prescribed Playwright command)
  • manually stress-tested repeated MenuButton open/close and selection, controlled Popover toggles, Tooltip hover cycles, and Autocomplete option selection; no ref/update-loop errors observed

Walkthrough

suspense_ref_components_working.mp4

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Co-authored-by: Cody Olsen <stipsan@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3fd1e07

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sanity/ui Patch
@sanity/themer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
icons Ready Ready Preview Aug 11, 2026 7:45pm
sanity-ui-storybook Ready Ready Preview Aug 11, 2026 7:45pm
ui-docs Ready Ready Preview Aug 11, 2026 7:45pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
sanity-ui-workshop Ignored Ignored Aug 11, 2026 7:45pm

Request Review

Co-authored-by: Cody Olsen <stipsan@users.noreply.github.com>
Co-authored-by: Cody Olsen <stipsan@users.noreply.github.com>
Co-authored-by: Cody Olsen <stipsan@users.noreply.github.com>

This branch was successfully deployed

3 active deployments
Preview – ui-docs 3fd1e070 Deployed Aug 11, 2026 by vercel[bot]
Preview – sanity-ui-storybook 3fd1e070 Deployed Aug 11, 2026 by vercel[bot]
Preview – icons 3fd1e070 Deployed Aug 11, 2026 by vercel[bot]
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.

2 participants