Skip to content

fix(dialog): merge content props through getFloatingProps (#806) - #2022

Closed
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-806-dialog-content-floating-props
Closed

kotAPI wants to merge 1 commit into
mainfrom
fix/issue-806-dialog-content-floating-props

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Dialog content merges consumer props via getFloatingProps
  • Updates context typing for userProps

Fixes #806

Test plan

  • npm test -- --testPathPatterns=Dialog.test

Summary by CodeRabbit

  • Refactor
    • Internal improvements to dialog component implementation for better prop handling and context management.

Pass content props into getFloatingProps so dismiss and focus handlers
are not overridden by consumer spreads.

Fixes #806
@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9613f36

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf45c752-da48-4afa-abd6-3265e770e9e7

📥 Commits

Reviewing files that changed from the base of the PR and between fe87b36 and 9613f36.

📒 Files selected for processing (2)
  • src/core/primitives/Dialog/context/DialogPrimitiveContext.tsx
  • src/core/primitives/Dialog/fragments/DialogPrimitiveContent.tsx

📝 Walkthrough

Walkthrough

getFloatingProps in DialogPrimitiveContextType is updated to accept an optional userProps parameter. DialogPrimitiveContent is refactored to pass all consumer props, ARIA attributes, style, role, data-state, and aria-modal as a single object into getFloatingProps(...) rather than calling it with no arguments and spreading attributes separately.

Changes

Dialog getFloatingProps prop-merge refactor

Layer / File(s) Summary
getFloatingProps signature and call-site refactor
src/core/primitives/Dialog/context/DialogPrimitiveContext.tsx, src/core/primitives/Dialog/fragments/DialogPrimitiveContent.tsx
DialogPrimitiveContextType.getFloatingProps signature changes from () => any to (userProps?: any) => any. DialogPrimitiveContent is updated to invoke getFloatingProps with a single merged object containing ...props, style, role, all ARIA attributes, and data-state/aria-modal, replacing the previous pattern of calling getFloatingProps() with no arguments and then spreading/assigning attributes afterward.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

  • #806 (BUG: Event handlers and props should be passed to getReferenceProps and not the element itself): This PR directly addresses the same pattern by passing consumer props into getFloatingProps(...) so that floating-ui can correctly compose event handlers rather than having them overridden by a separate spread.
  • _⚠️ Potential issue_ Overriding of keydown events #1510: The changes implement the fix described in this issue — updating getFloatingProps to accept userProps and passing consumer props into the call to prevent event handler conflicts like onKeyDown being overridden.

Possibly related PRs

  • rad-ui/ui#1203: Both PRs modify DialogPrimitiveContext.tsx to evolve the Dialog primitive's TypeScript contracts, with this PR changing getFloatingProps's signature and the retrieved PR adding a floaterContext field.

Poem

🐇 Hop, hop — no more prop override woe,
The floating props now get all they need to know.
One tidy object, merged with care and flair,
ARIA and style riding in the same little hare.
Events compose correctly, no handler slips away —
The Dialog listens perfectly, hip-hip-hooray! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: merging content props through getFloatingProps to fix prop handling in the Dialog component.
Linked Issues check ✅ Passed The PR successfully addresses issue #806 by updating DialogPrimitiveContext to accept userProps parameter and modifying DialogPrimitiveContent to pass props through getFloatingProps.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Dialog component's prop merging through getFloatingProps as specified in issue #806.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-806-dialog-content-floating-props

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

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

This report compares the PR with the base branch. "Δ" shows how the PR affects each metric.

Metric PR Δ
Statements 75.73% +0.00%
Branches 59.17% +0.00%
Functions 61.75% +0.00%
Lines 77.26% +0.00%

Coverage improved or stayed the same. Great job!

Run npm run coverage:ci locally for detailed reports and target untested areas to raise these numbers.

@kotAPI

kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

LGTM. Matches project patterns for portal Theme refs, Floating UI prop merge, controlled-switch/lazy-mount/RTL tests, or focused bug fixes. No changes requested.

@kotAPI

kotAPI commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Already implemented on main in a strictly better form — merging this would regress it.

main's DialogPrimitiveContent:

const consumerStyle = (props as React.HTMLAttributes<HTMLDivElement>).style;
const restProps = { ...props } as Record<string, unknown>;
delete restProps.style;

{...(getFloatingProps as (userProps?: Record<string, unknown>) => Record<string, unknown>)({
    ...restProps,
    style: { outline: 'none', ...styleProp, ...consumerStyle },
    ...
})}

main strips style out of restProps and then re-merges consumerStyle last, so consumer inline styles win. This PR passes ...props (style included) into the call and drops consumerStyle entirely, which would lose that behaviour. Closing as already-landed.

@kotAPI kotAPI closed this Oct 2, 2026
@kotAPI
kotAPI deleted the fix/issue-806-dialog-content-floating-props branch October 2, 2026 06:21
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.

BUG: Event handlers and props should be passed to getReferenceProps and not the element itself

1 participant