From fda894ab42fe25bda327c840a040d11f93092f8b Mon Sep 17 00:00:00 2001 From: Rohan Chakraborty Date: Mon, 19 Oct 2026 00:28:06 +0530 Subject: [PATCH 1/3] feat: pass a details object to every change callback --- .../skills/apsara/references/composition.md | 2 + .../src/content/docs/(overview)/upgrading.mdx | 45 +++++++++++++ .../docs/ai-elements/chat-panel/props.ts | 5 +- .../docs/ai-elements/prompt-input/props.ts | 5 +- .../docs/ai-elements/reasoning/props.ts | 5 +- .../docs/components/accordion/props.ts | 7 +- .../docs/components/code-block/props.ts | 5 +- .../docs/components/color-picker/index.mdx | 2 +- .../docs/components/color-picker/props.ts | 11 +++- .../content/docs/components/combobox/props.ts | 14 ++-- .../docs/components/context-menu/props.ts | 10 ++- .../content/docs/components/editor/props.ts | 10 ++- .../docs/components/filter-chip/index.mdx | 2 +- .../docs/components/filter-chip/props.ts | 4 +- .../src/content/docs/components/menu/props.ts | 10 ++- .../content/docs/components/select/props.ts | 12 ++++ .../content/docs/components/sidebar/props.ts | 10 ++- .../docs/components/textarea/index.mdx | 2 +- .../content/docs/components/textarea/props.ts | 4 +- apps/www/src/content/docs/dataview/props.ts | 5 +- .../accordion/__tests__/accordion.test.tsx | 11 ++++ .../components/accordion/accordion-root.tsx | 27 ++++++-- .../chat-panel/__tests__/chat-panel.test.tsx | 7 +- .../chat-panel/chat-panel-context.tsx | 10 +-- .../chat-panel/chat-panel-parts.tsx | 4 +- .../components/chat-panel/chat-panel-root.tsx | 27 ++++++-- .../chat-panel/chat-panel-trigger.tsx | 2 +- .../code-block/__tests__/code-block.test.tsx | 7 +- .../components/code-block/code-block-misc.tsx | 2 +- .../components/code-block/code-block-root.tsx | 26 ++++++-- .../__tests__/color-picker.test.tsx | 12 +++- .../color-picker/color-picker-alpha.tsx | 4 +- .../color-picker/color-picker-area.tsx | 47 ++++++++++---- .../color-picker/color-picker-hue.tsx | 13 ++-- .../color-picker/color-picker-input.tsx | 10 +-- .../color-picker/color-picker-root.tsx | 27 ++++++-- .../combobox/__tests__/combobox.test.tsx | 33 +++++++--- .../components/combobox/combobox-input.tsx | 7 +- .../components/combobox/combobox-root.tsx | 28 ++++++-- .../context-menu/context-menu-content.tsx | 2 +- .../context-menu/context-menu-root.tsx | 41 +++++++++--- .../data-view/__tests__/data-view.test.tsx | 25 +++++++ .../data-view/components/view-switcher.tsx | 8 ++- .../react/components/data-view/data-view.tsx | 9 ++- .../components/data-view/data-view.types.tsx | 9 ++- .../editor/core/mention-registry.ts | 3 +- .../editor/core/use-suggestion-menu.ts | 17 +++-- .../components/editor/editor-mentions.tsx | 7 +- .../components/editor/editor-slash-menu.tsx | 7 +- .../__tests__/filter-chip.test.tsx | 48 ++++++++++---- .../components/filter-chip/filter-chip.tsx | 65 +++++++++++++++---- .../components/menu/__tests__/menu.test.tsx | 10 ++- .../react/components/menu/menu-content.tsx | 2 +- packages/react/components/menu/menu-root.tsx | 46 ++++++++++--- .../__tests__/prompt-input-mentions.test.tsx | 7 +- .../prompt-input/prompt-input-mentions.tsx | 3 +- .../reasoning/__tests__/reasoning.test.tsx | 28 ++++++-- .../react/components/reasoning/reasoning.tsx | 21 ++++-- .../select/__tests__/select.test.tsx | 32 +++++++-- .../react/components/select/select-root.tsx | 35 +++++++--- .../sidebar/__tests__/sidebar.test.tsx | 25 ++++--- .../components/sidebar/sidebar-group.tsx | 12 +++- .../react/components/sidebar/sidebar-root.tsx | 24 +++++-- .../components/sidebar/sidebar-trigger.tsx | 3 +- .../text-area/__tests__/text-area.test.tsx | 6 +- .../react/components/text-area/text-area.tsx | 10 ++- packages/react/shared/change-details.ts | 30 +++++++++ 67 files changed, 786 insertions(+), 223 deletions(-) create mode 100644 packages/react/shared/change-details.ts diff --git a/.agents/skills/apsara/references/composition.md b/.agents/skills/apsara/references/composition.md index c6c679642..82ed00651 100644 --- a/.agents/skills/apsara/references/composition.md +++ b/.agents/skills/apsara/references/composition.md @@ -65,6 +65,8 @@ const [open, setOpen] = useState(false); ``` +Change callbacks (`onValueChange`, `onOpenChange`, `onInputValueChange`, and the like) take the new value first and a details object second: Base UI's `eventDetails` on components that wrap Base UI, or `details` with the same `reason` and `event` on components that own their state. Component data is a field of that object, for example `details.mode` on `ColorPicker` and `details.operation` on `FilterChip`. + Several overlay roots (`Dialog`, `Menu`, `Popover`, `Tooltip`) also expose `createHandle` for advanced imperative open/close from outside the subtree — use only when a trigger can't live in the same tree. ## Select diff --git a/apps/www/src/content/docs/(overview)/upgrading.mdx b/apps/www/src/content/docs/(overview)/upgrading.mdx index 82f756aad..efbd3ec3f 100644 --- a/apps/www/src/content/docs/(overview)/upgrading.mdx +++ b/apps/www/src/content/docs/(overview)/upgrading.mdx @@ -7,6 +7,51 @@ One section per release, newest first, with only the changes that need action from you. The full record of every release, features and fixes included, is on [GitHub releases](https://github.com/raystack/apsara/releases). +## Unreleased: change callbacks get a details object + +Every change callback now passes a second argument after the value. A +component that wraps Base UI passes Base UI's `eventDetails`. A component that +keeps its own state passes a `details` object with the same `reason` and +`event` fields, plus any field of its own. + +### 1. Update the three callbacks whose second argument changes + +| `onValueChange` | Before | After | +|---|---|---| +| `TextArea` | `(value, event)` | `(value, eventDetails)` | +| `ColorPicker` | `(value, mode)` | `(value, details)` | +| `FilterChip` | `(value, operation)` | `(value, details)` | + +TextArea's `event` was the React `ChangeEvent`. `eventDetails.event` is the +native event. ColorPicker's mode is `details.mode`, and FilterChip's operation +is `details.operation`. + +```tsx +// Before + save(value, mode)} /> + apply(value, operation)} /> +