Skip to content

[dialog] Fix DialogTitle forwardRef type - #3736

Merged
ZeeshanTamboli merged 2 commits into
mui:masterfrom
ZeeshanTamboli:fix-dialog-title-ref-type
Jan 14, 2026
Merged

ZeeshanTamboli merged 2 commits into
mui:masterfrom
ZeeshanTamboli:fix-dialog-title-ref-type

Conversation

@ZeeshanTamboli

Copy link
Copy Markdown
Member

No description provided.

@ZeeshanTamboli ZeeshanTamboli added type: bug It doesn't behave as expected. component: dialog Changes related to the dialog component. typescript labels Jan 14, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 14, 2026 •

Copy link
Copy Markdown
  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3736
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3736
    

commit: d4d00a0

@netlify

netlify Bot commented Jan 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit df867e8
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6967421e190a1200082af27c
😎 Deploy Preview https://deploy-preview-3736--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot

mui-bot commented Jan 14, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jan 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit d4d00a0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/696742397455ea00084cd089
😎 Deploy Preview https://deploy-preview-3736--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ZeeshanTamboli
ZeeshanTamboli marked this pull request as ready for review January 14, 2026 07:19
@greptile-apps

greptile-apps Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixed the forwardRef type for DialogTitle from React.ForwardedRef<HTMLParagraphElement> to React.ForwardedRef<HTMLHeadingElement> to correctly match the h2 element that the component renders.

  • The component renders an <h2> element (line 25) but the ref type was incorrectly typed as HTMLParagraphElement
  • This brings DialogTitle into consistency with similar heading components like ToastTitle and AccordionHeader, which correctly use HTMLHeadingElement
  • The existing test already expects window.HTMLHeadingElement (DialogTitle.test.tsx:8), confirming this fix aligns with expected behavior
  • The interface DialogTitleProps correctly extends BaseUIComponentProps<'h2', ...> (line 31), making the previous ref type inconsistent

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a simple type correction that fixes an incorrect type annotation. The component renders an h2 element, so the ref type should be HTMLHeadingElement, not HTMLParagraphElement. This is a pure TypeScript fix with no runtime behavior changes. The existing tests already expect the correct type, and the change aligns with other similar heading components in the codebase.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/dialog/title/DialogTitle.tsx Fixed forwardRef type from HTMLParagraphElement to HTMLHeadingElement to match the actual h2 element being rendered

Sequence Diagram

sequenceDiagram
    participant User
    participant DialogTitle
    participant React
    participant DOM

    User->>DialogTitle: Pass ref prop
    DialogTitle->>React: forwardRef with HTMLHeadingElement type
    React->>DialogTitle: Call component function
    DialogTitle->>DialogTitle: useRenderElement('h2', ...)
    DialogTitle->>DOM: Render <h2> element
    DialogTitle->>React: Attach ref to HTMLHeadingElement
    React->>User: Return ref with correct type
Loading

@ZeeshanTamboli
ZeeshanTamboli merged commit b870679 into mui:master Jan 14, 2026
@ZeeshanTamboli
ZeeshanTamboli deleted the fix-dialog-title-ref-type branch January 14, 2026 07:34
atomiks pushed a commit to atomiks/base-ui that referenced this pull request Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: dialog Changes related to the dialog component. type: bug It doesn't behave as expected. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants