[floating-ui] Remove interaction wrappers#4757
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,228.10 ms 🔺+207.63 ms(+20.3%) | Renders: 50 (+0) | Paint: 1,885.44 ms 🔺+336.41 ms(+21.7%)
…and 7 more — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e572493 to
8d2d75d
Compare
8d2d75d to
5f71c92
Compare
There was a problem hiding this comment.
Pull request overview
Removes Floating UI “interaction wrapper” hooks (useInteractions, useRole) from the runtime surface and updates Base UI components/tests to merge interaction props directly at call sites, while keeping a getter-style helper for tests (useTestInteractions) to preserve existing test ergonomics.
Changes:
- Dropped runtime exports for
useInteractions/useRoleand updated internal types accordingly. - Updated Select/Combobox/Menu/Navigation Menu runtime code to explicitly merge hook props (and apply ARIA props directly where needed).
- Converted Floating UI test fixtures and hook/component tests to use
useTestInteractionsand/or direct prop merging.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react/test/useTestInteractions.ts | Renames and rehomes the interactions prop-getter helper for tests (useTestInteractions). |
| packages/react/test/index.ts | Re-exports useTestInteractions from test utilities. |
| packages/react/test/floating-ui-tests/Popover.tsx | Updates fixture to use useTestInteractions and spells out dialog ARIA props. |
| packages/react/test/floating-ui-tests/Navigation.tsx | Updates fixture to use useTestInteractions. |
| packages/react/test/floating-ui-tests/MenuOrientation.tsx | Replaces useRole usage with explicit menu ARIA props + useTestInteractions. |
| packages/react/test/floating-ui-tests/Menu.tsx | Replaces useRole usage with explicit menu ARIA props + useTestInteractions. |
| packages/react/test/floating-ui-tests/ListboxFocus.tsx | Removes useRole and applies listbox role/id directly. |
| packages/react/test/floating-ui-tests/Grid.tsx | Updates fixture to use useTestInteractions. |
| packages/react/test/floating-ui-tests/EmojiPicker.tsx | Replaces useRole with local ARIA props object used via useTestInteractions. |
| packages/react/test/floating-ui-tests/ComplexGrid.tsx | Updates fixture to use useTestInteractions. |
| packages/react/src/select/root/SelectRootContext.ts | Replaces getItemProps API with static itemProps on context. |
| packages/react/src/select/root/SelectRoot.tsx | Removes useInteractions; explicitly merges interaction props and stores popupProps/itemProps. |
| packages/react/src/select/item/SelectItem.tsx | Consumes itemProps instead of calling getItemProps. |
| packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx | Replaces useInteractions with mergeProps for reference interactions. |
| packages/react/src/menu/trigger/MenuTrigger.tsx | Replaces useInteractions with direct prop merging for trigger interactions. |
| packages/react/src/menu/submenu-trigger/MenuSubmenuTrigger.tsx | Replaces useInteractions with direct click.reference usage. |
| packages/react/src/menu/root/MenuRoot.tsx | Removes useRole/useInteractions; builds trigger/popup/item props explicitly. |
| packages/react/src/floating-ui-react/types.ts | Moves/adjusts exported types to reflect removal of wrappers. |
| packages/react/src/floating-ui-react/index.ts | Removes runtime exports for useInteractions and useRole. |
| packages/react/src/floating-ui-react/hooks/useTypeahead.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useListNavigation.ts | Updates docs to remove useRole() reference. |
| packages/react/src/floating-ui-react/hooks/useListNavigation.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useInteractions.test.tsx | Removes tests for the deleted useInteractions hook. |
| packages/react/src/floating-ui-react/hooks/useHover.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useDismiss.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useClientPoint.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useClick.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/components/FloatingFocusManager.test.tsx | Switches tests from useInteractions (and useRole) to useTestInteractions + local ARIA props. |
| packages/react/src/floating-ui-react/components/FloatingDelayGroup.test.tsx | Switches tests from useInteractions to useTestInteractions. |
| packages/react/src/floating-ui-react/hooks/useRole.ts | Removes the deleted useRole hook implementation. |
| packages/react/src/combobox/store.ts | Replaces getItemProps with stored itemProps in combobox state/selectors. |
| packages/react/src/combobox/root/AriaCombobox.tsx | Removes useInteractions; explicitly merges input/popup/item props and stores them. |
| packages/react/src/combobox/item/ComboboxItem.tsx | Consumes stored itemProps instead of calling getItemProps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const menuRoleProps = React.useMemo( | ||
| () => ({ | ||
| reference: { | ||
| 'aria-haspopup': 'menu' as const, | ||
| 'aria-expanded': open, | ||
| 'aria-controls': open ? context.floatingId : undefined, | ||
| }, | ||
| floating: { | ||
| id: context.floatingId, | ||
| role: 'menu' as const, | ||
| }, | ||
| }), |
Code Review (GPT-5.5 + Opus 4.7)Approve ✅: the two previously noted nits are addressed, and I do not see remaining actionable issues in the refreshed full-branch diff. 1. Remaining Bugs / Issues (None)No remaining branch-relevant bugs or review nits found. Previous Review Issues StatusThe stale The moved interaction-merging helper now has direct regression coverage for handler composition, undefined handlers, non-event Behavior Preservation AssessmentThe direct Test Coverage AssessmentI verified the follow-up locally with |
This removes the internal interaction wrapper hooks and keeps interaction prop merging at the call sites that still need it. Runtime code now uses direct hook props, while tests use a local helper for the old getter-style ergonomics.
Changes
useInteractionsfrom the Floating UI runtime exports and move the helper behavior intouseTestInteractionsfor tests.useRoleand spell out the small role/ARIA props directly in the Menu and test fixture call sites that used it.