Skip to content

feat!: type child and slot contracts and add a trigger prop - #3272

Merged
interactivellama merged 7 commits into
masterfrom
feat/v11-child-slot-contracts
Nov 6, 2026
Merged

interactivellama merged 7 commits into
masterfrom
feat/v11-child-slot-contracts

Conversation

@Niznikr

@Niznikr Niznikr commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

  • trigger prop on Tooltip and MenuDropdown. It takes either:

    • an element, which the component merges its trigger props into, or
    • a function that receives TooltipTriggerProps / MenuDropdownTriggerProps, for full control.

    When you pass an element, the consumer's props win, the consumer's handlers run first, and className / aria-describedby / aria-labelledby are joined. A Button passed to MenuDropdown takes the dropdown's button props as defaults. Passing the trigger as children (or as a DropdownTrigger child) still works, goes through the same merge, and warns once (utilities/warning/children-as-trigger).

  • Popover keeps its children (maintainer decision). The first child is the element the popover attaches to, which need not be a button (for example a walkthrough step pointing at a Card's toolbar), so Popover gets no trigger prop and its trigger handling is unchanged. New openOn="none" makes the first child only an anchor: Popover positions against it and adds nothing to it (no id, aria-haspopup, tabIndex or handlers), and the parent opens and closes it through isOpen.

  • Typed library-component children. These components now type the children they accept and keep the props they inject in internal *InjectedProps types: accordion, alert, builder-header, button-group, files, input, page-header controls, panel filter list, radio-group, radio-button-group, scoped-notification, setup-assistant, simple-data-table, tabs, toast, visual-picker and welcome-mat. Children that were found by displayName are now matched by reference with isElementOfType.

  • Combobox popover / input / tooltipMenuItemDisabled are typed and the consumer's props win. input's onChange is wrapped so both handlers run. The disabled-item tooltip gets its trigger through trigger.

  • Filter declares errorLabel, which PanelFilterList already reads.

  • New utilities: utilities/is-element-of-type, utilities/merge-props (mergeProps, renderTrigger, TriggerRender) and ChildrenOf<P> in types/common.

Breaking changes (each has a BREAKING CHANGE: footer in its commit):

  • Tooltip and MenuDropdown merge trigger props instead of overwriting them. The trigger's own handlers now run, before the component's. Its aria-describedby is joined with Tooltip's, and its className is joined with MenuDropdown's. Passing the trigger as children is deprecated in favor of trigger.
  • Children and slots are typed as the library components they accept (for example Alert / Toast icon as ReactElement<IconProps>). Injected props are no longer in the public child types.
  • BuilderHeader, MenuDropdown, PageHeader controls, SetupAssistant and SimpleDataTable no longer treat a component that copies a library component's displayName as that component.
  • Combobox: popover, input and tooltipMenuItemDisabled are typed as Popover, Input and Tooltip elements, and the input element's onChange runs alongside the combobox's handler, called with (event, { value }).

Popover is not breaking: its children contract and trigger behavior are unchanged, and openOn="none" is additive.

Migration:

  • Tooltip: replace <Tooltip …><Button/></Tooltip> with <Tooltip … trigger={<Button/>} />.
  • MenuDropdown: replace <MenuDropdown …><DropdownTrigger><Button/></DropdownTrigger></MenuDropdown> with <MenuDropdown … trigger={<Button/>} />.
  • Popover: no change. For a walkthrough or other non-interactive target, add openOn="none" and control isOpen.
  • Custom SimpleDataTable cells and other custom children no longer need to copy a library displayName. Wrap the library component instead (see the SimpleDataTable examples).
  • Deprecated: TabChildProps (use TabsPanelProps) and FileChildProps (use FileProps).

Bugs fixed: root causes and regression tests

  • Tooltip / MenuDropdown triggers lost their own onFocus / onMouse* / onClick handlers and aria-describedby. The components cloned the child and overwrote those props. Tooltip also threw when given several children. Tests: tooltip-trigger.test.jsx, menu-dropdown-trigger.test.jsx.

  • Popover: a walkthrough step on a non-interactive anchor made it focusable, announced it as opening a dialog, and toggled the step on click. Popover always cloned its first child with id, aria-haspopup, tabIndex and open handlers. Fixed with openOn="none". Test: popover-anchor.test.jsx.

  • MenuDropdown custom content remounted on every render. Each child was cloned with key: generateId(), a new key every time. Test: menu-dropdown-trigger.test.jsx (fails against the old key).

  • PanelFilterList: an errored filter with no id had a dangling aria-describedby. The list rendered the error under its own generated id but didn't pass that id to the filter. Test: panel-filter-list.test.jsx.

  • ButtonGroup: with a trailing null / false child, the real last button wasn't marked slds-button_last. The last child was picked by index over Children.count, which counts empty children. Test: button-group-children.test.jsx.

  • ScopedNotification: a string assistiveText on the icon element was lost. It was spread as an object. Test: scoped-notification.test.jsx.

  • SimpleDataTable:

    • custom cells only rendered if they copied the cell's displayName
    • conditional (false) columns were counted for keyboard navigation
    • a consumer RowActions menuPosition was overwritten in fixedHeader tables

    Test: simple-data-table-children.test.jsx.

  • RadioGroup / VisualPicker overwrote a child's name, and RadioGroup also replaced the child's aria-describedby with its error id. Tests: radio-group-children.test.jsx, visual-picker-children.test.jsx.

  • Combobox: the input element's onChange replaced the combobox's handler and got a native-style call. The input's props were spread last onto the private InnerInput. Test: combobox-slots.test.jsx.

Reference matching and utilities are covered by builder-header-children, setup-assistant-children, files, merge-props and children-as-trigger tests.

Snapshot diff: 7 changed lines and one new story.

  • The BuilderHeader (AfterSuccessfulSave, FailedSave, SuccessfulSave, WithToolbar, WithUtilities) and SimpleDataTable JoinedWithPageHeader MenuDropdown Button triggers now keep the dropdown's ignore-click-* class, because className is joined instead of replaced.
  • New story: Popover WalkthroughOnAnchor (openOn="none" on a Card toolbar).

All other story markup is unchanged.

Examples and stories migrated from a children trigger to trigger (before: trigger passed as children or a DropdownTrigger child; after: trigger prop on Tooltip or MenuDropdown). A scan of all examples and stories finds no remaining Tooltip or MenuDropdown children triggers. Popover examples are unchanged.

  • components/builder-header/__docs__/BuilderHeader.stories.jsx
  • components/builder-header/__examples__/after-successful-save.jsx
  • components/builder-header/__examples__/base-with-page-type-editable.jsx
  • components/builder-header/__examples__/failed-save.jsx
  • components/menu-dropdown/__docs__/MenuDropdown.stories.tsx
  • components/menu-dropdown/__examples__/custom-trigger.jsx
  • components/page-header/__examples__/object-home.jsx
  • components/page-header/__examples__/related-list.jsx
  • components/simple-data-table/__examples__/joined-with-page-header.jsx
  • components/split-view/__examples__/base-multiple.jsx
  • components/split-view/__examples__/base.jsx
  • components/split-view/__examples__/custom-items-list.jsx
  • components/split-view/__examples__/external-state.jsx
  • components/tooltip/__docs__/Tooltip.stories.jsx
  • components/tooltip/__examples__/button-group.jsx
  • components/tooltip/__examples__/button.jsx

Other example and story changes:

  • The 13 SimpleDataTable examples no longer copy SimpleDataTableCell.displayName onto their custom cell, because cells are matched by reference.
  • Combobox.stories.tsx PopoverVariant: the popover element drops its {null} children.
  • Popover.stories.jsx: adds WalkthroughOnAnchor.

Still open (noted in ROADMAP.md):

  • builder-header's toolbar reads label from ButtonGroup children, which isn't a ButtonGroup prop
  • popover check-props.js is never called
  • Popover's isTriggerTabbable still guesses from displayName
  • MenuDropdown keeps the MENU_DROPDOWN_TRIGGER lookup for custom trigger templates until the deprecated child trigger is removed

Commits:

  1. style: Prettier-only formatting of the touched files
  2. utilities
  3. trigger prop (Tooltip, MenuDropdown)
  4. typed children
  5. combobox
  6. Popover openOn="none"
  7. docs (CHANGELOG, ROADMAP, codebase overview)

Local runs: npm run test:ci passes (1539 tests; lint has 0 errors and no new warnings in the files this PR adds).


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

    • npm run lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
    • npm run typecheck is clean (tsc --noEmit).
    • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
    • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
    • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
    • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
    • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

*/
children?: ReactNode;
children?: ChildrenOf<
BuilderHeaderNavLinkProps | BuilderHeaderNavDropdownProps

@interactivellama interactivellama Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Many of these child types make sense and maybe we hint at this options and add a | ReactNode to the end. I would expect a consumer to want to put their own type of children in the navigation or the builder editor. @Niznikr

We may want to remove this typing for BuilderHeader

Never mind. I saw the displayName check in the old code It's only BuilderHeaderMisc that accepts non-specific components. These others should be typed.

@interactivellama

interactivellama commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

@Niznikr We will want to pull back on using props for the triggers for the dialog-using element. For instance, in a first-time UX walkthrough, the Popover could be attached to a non-button in order to tell the user what the Card org toolbar does.

Niznikr and others added 7 commits November 5, 2026 16:57
Prettier only, so the functional commits that follow show just the
behavior changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- isElementOfType matches a child by component reference instead of
  displayName, and narrows its props type
- ChildrenOf<P> types children that must be elements of a component
- mergeProps merges a component's props into a consumer element's:
  consumer props win, handlers and refs are composed (consumer first),
  className and aria-describedby/labelledby are joined without
  duplicates, and style objects are merged
- renderTrigger renders a TriggerRender slot: an element (merged with
  mergeProps) or a function that receives the trigger props
- warning/children-as-trigger warns once when a trigger is passed as
  children

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tooltip and MenuDropdown take a trigger prop. An element is merged with
the component's trigger props through mergeProps, so the consumer's
props win, its handlers run before the component's, and
className/aria-describedby are joined. A function receives the trigger
props (TooltipTriggerProps, MenuDropdownTriggerProps) for full control.
For MenuDropdown, a Button element takes the dropdown's button props as
defaults.

Root cause of the old behavior: both components cloned their trigger
child and overwrote the props they needed, so a trigger lost its own
handlers and aria-describedby. The trigger passed as children (and the
MenuDropdown DropdownTrigger child) still works, goes through the same
merge, and warns once.

Popover keeps its children: the wrapped element is what the popover
attaches to, which need not be a button (for example a walkthrough step
on a toolbar).

Also:
- MenuDropdown matches List and Button children by reference, and
  custom content keeps a stable key instead of remounting each render
- Tooltip no longer throws when given several children
- TrialBarDropdown passes its children to the menu
- Library uses (button, progress-indicator, builder-header nav,
  menu-list, trial-bar) and the examples and stories use trigger

BREAKING CHANGE: Tooltip and MenuDropdown merge trigger props instead of
overwriting them. The trigger's own handlers now run, before the
component's; its aria-describedby is joined with Tooltip's; and its
className is joined with MenuDropdown's. Passing the trigger as
children is deprecated in favor of trigger.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Parents that read or clone their children (accordion, alert,
builder-header, button-group, files, input, page-header controls,
panel filter list, radio-group, radio-button-group, scoped-notification,
setup-assistant, simple-data-table, tabs, toast, visual-picker,
welcome-mat) now type the children they accept, keep the props they
inject in internal *InjectedProps types, and find children with
isElementOfType instead of comparing displayName.

Root causes of the bugs fixed along the way:
- PanelFilterList gave an errored filter without an id no id, so the
  filter's aria-describedby pointed at a missing error element
- ButtonGroup marked the last child by index over all children, so a
  trailing null/false child left the real last button unmarked
- ScopedNotification spread the icon's assistiveText as an object, so a
  string one was lost
- SimpleDataTable required custom cells to copy the cell displayName,
  counted conditional (false) columns for keyboard navigation, and
  overwrote a consumer RowActions menuPosition in fixedHeader tables
- RadioGroup and VisualPicker cloned name over the child's own, and
  RadioGroup replaced the child's aria-describedby with its error id

Filter declares errorLabel, which PanelFilterList already reads.

TabChildProps and FileChildProps are deprecated aliases of
TabsPanelProps and FileProps.

BREAKING CHANGE: Children and slots are typed as the library components
they accept (e.g. Alert and Toast icon as ReactElement<IconProps>), and
injected props are no longer part of the public child types.
BuilderHeader, MenuDropdown, PageHeader controls, SetupAssistant and
SimpleDataTable no longer treat a component that copies a library
component's displayName as that component.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The three element props are typed as the library components they take
(ReactElement<Partial<PopoverProps>>, ReactElement<Partial<InputProps>>,
ReactElement<Partial<TooltipProps>>), and their props win over the
combobox's defaults. The disabled-item tooltip gets its trigger through
trigger instead of children.

Root cause of the onChange bug: the input element's props were spread
last onto the private InnerInput, so an Input-style
onChange(event, { value }) replaced the combobox's handler and got a
native call. It is now wrapped: called with (event, { value }), then the
combobox's own handler runs.

BREAKING CHANGE: popover, input and tooltipMenuItemDisabled are typed as
Popover, Input and Tooltip elements, and the input's onChange runs
alongside the combobox's handler with (event, { value }).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A walkthrough step points at part of the page, such as a Card's
toolbar, rather than at a button that opens it. Popover always cloned
its first child with id, aria-haspopup, tabIndex and click/hover
handlers, which made such an anchor focusable, announced it as opening
a dialog, and toggled the step when the user clicked it.

With openOn="none" the first child is only an anchor: Popover positions
against it and adds nothing to it, and the parent opens and closes the
popover through isOpen. Other openOn values behave as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CHANGELOG entries for the trigger prop and the typed child contracts,
the theme 3 status and per-component notes in ROADMAP.md (including the
decision to keep Popover's children as its anchor), and the utilities to
use in the codebase overview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Niznikr
Niznikr force-pushed the feat/v11-child-slot-contracts branch from c641faf to 9175674 Compare November 5, 2026 22:45
* child gets `slds-button_last` added to its `triggerClassName`. Checkbox children default
* to `variant="button-group"` and are described by `labels.error`.
*/
children: ChildrenOf<ButtonProps | MenuDropdownProps | CheckboxProps>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A Tooltip wrapped button might be likely.

@interactivellama

Copy link
Copy Markdown
Contributor

A related trigger props thread in Base UI's issues. mui/base-ui#3983

@interactivellama
interactivellama merged commit 62499aa into master Nov 6, 2026
11 checks passed
@interactivellama
interactivellama deleted the feat/v11-child-slot-contracts branch November 6, 2026 00:48
interactivellama added a commit that referenced this pull request Nov 6, 2026
* docs: update roadmap P1 status and drop the boolean renames

Tick the completed P1 items (entry points, release tag format) and bump the
status line to 11.0.0-alpha.8. Remove the Booleans theme and the per-component
is*/has* rename findings, which were cancelled for v11.

* docs: tick roadmap items removed in #3248

The deprecated-surface removal in 11.0.0-alpha.6 closed InlineEdit, ModalTrigger, the
forms/checkbox and tabs/pane aliases, and the string assistiveText forms. Tick those
items and trim the finished parts from the mixed ones.

* docs: update roadmap status against master after #3272

Tick items fixed on master, add partly-done notes, merge #3272's roadmap
changes and bump the version to 11.0.0-alpha.10.
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