Skip to content

refactor: use base ui useControlled for controlled state - #966

Open
Shreyag02 wants to merge 1 commit into
mainfrom
refactor/use-controlled
Open

Shreyag02 wants to merge 1 commit into
mainfrom
refactor/use-controlled

Conversation

@Shreyag02

Copy link
Copy Markdown
Contributor

Summary

  • Use Base UI's useControlled for the controlled and uncontrolled state of Sidebar, Sidebar.Group, Select, DataView, Menu, ContextMenu and their submenus, Combobox, Command, CodeBlock, and ColorPicker mode, in place of the hand-written merges. Tour, Reasoning, ChatPanel, PromptInput and CalendarPreview already use it, so this follows them instead of adding a new hook.
  • Behavior change: these props now pick controlled or uncontrolled on the first render and keep it, as Base UI components do. A prop that is undefined on the first render and set later is ignored, and a controlled prop that later becomes undefined no longer falls back to internal state. Base UI logs a warning in development for both. The Base UI roots under Select, Combobox and Command already did this for value, and the value Apsara reads now matches them.
  • Fix CodeBlock calling onCollapseChange with the wrong value when collapsed is controlled, and calling it twice per click in Strict Mode.
  • Pass '' to the language Select of CodeBlock.LanguageSelect until a CodeBlock.Code sets the value, so its trigger shows the language when CodeBlock has no value or defaultValue.
  • Add tests for controlled Menu and ContextMenu, the Menu and Select search value, the ColorPicker mode, and the CodeBlock fixes.

Closes #876

@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
apsara Ready Ready Preview Oct 11, 2026 7:27pm UTC

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e951b3c-b715-428b-af17-93dac43cbcff

📥 Commits

Reviewing files that changed from the base of the PR and between 86eb92b and 9cec590.


📒 Files selected for processing (16)
  • packages/react/components/code-block/__tests__/code-block.test.tsx
  • packages/react/components/code-block/code-block-language-select.tsx
  • packages/react/components/code-block/code-block-root.tsx
  • packages/react/components/color-picker/__tests__/color-picker.test.tsx
  • packages/react/components/color-picker/color-picker-root.tsx
  • packages/react/components/combobox/combobox-root.tsx
  • packages/react/components/command/command-root.tsx
  • packages/react/components/context-menu/__tests__/context-menu.test.tsx
  • packages/react/components/context-menu/context-menu-root.tsx
  • packages/react/components/data-view/data-view.tsx
  • packages/react/components/menu/__tests__/menu.test.tsx
  • packages/react/components/menu/menu-root.tsx
  • packages/react/components/select/__tests__/select.test.tsx
  • packages/react/components/select/select-root.tsx
  • packages/react/components/sidebar/sidebar-group.tsx
  • packages/react/components/sidebar/sidebar-root.tsx

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@raystack/apsara@966

commit: 9cec590

This branch was successfully deployed

1 active deployment
Preview — 9cec5903 Deployed Oct 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.

Add a shared useControllableState hook

1 participant