Skip to content

[combobox] Fix the type of the ref of the Icon part#3796

Merged
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:comboboxicon-span
Jan 20, 2026
Merged

[combobox] Fix the type of the ref of the Icon part#3796
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:comboboxicon-span

Conversation

@flaviendelangle

@flaviendelangle flaviendelangle commented Jan 20, 2026

Copy link
Copy Markdown
Member

Fixes #3790

We have a some components the use HTMLElement instead of the exact typing, which most of them use the exact typing (HTMLDivElement, HTMLSpanElement, etc...)

Is there a reason to have this distinction?

File Current Ref Type Rendered Element Should Be
packages/react/src/button/Button.tsx HTMLElement button HTMLButtonElement
packages/react/src/checkbox/root/CheckboxRoot.tsx HTMLElement span HTMLSpanElement
packages/react/src/radio/root/RadioRoot.tsx HTMLElement span HTMLSpanElement
packages/react/src/switch/root/SwitchRoot.tsx HTMLElement span HTMLSpanElement
packages/react/src/tabs/tab/TabsTab.tsx HTMLElement button HTMLButtonElement
packages/react/src/accordion/trigger/AccordionTrigger.tsx HTMLElement button HTMLButtonElement
packages/react/src/popover/trigger/PopoverTrigger.tsx HTMLElement button HTMLButtonElement
packages/react/src/menu/item/MenuItem.tsx HTMLElement div HTMLDivElement
packages/react/src/menu/checkbox-item/MenuCheckboxItem.tsx HTMLElement div HTMLDivElement
packages/react/src/menu/radio-item/MenuRadioItem.tsx HTMLElement div HTMLDivElement
packages/react/src/menu/submenu-trigger/MenuSubmenuTrigger.tsx HTMLElement div HTMLDivElement
packages/react/src/select/item/SelectItem.tsx HTMLElement div HTMLDivElement

@flaviendelangle flaviendelangle self-assigned this Jan 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 20, 2026

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

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

commit: 135eddc

@netlify

netlify Bot commented Jan 20, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 135eddc
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/696f5311981f2400085ccf8a
😎 Deploy Preview https://deploy-preview-3796--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 20, 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.

@flaviendelangle flaviendelangle added type: bug It doesn't behave as expected. typescript component: combobox Changes related to the combobox component. labels Jan 20, 2026
@flaviendelangle flaviendelangle marked this pull request as ready for review January 20, 2026 09:37
@greptile-apps

greptile-apps Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixed the ref type for Combobox.Icon from HTMLDivElement to HTMLSpanElement to correctly match the rendered element type.

  • Changed forwardedRef parameter type in ComboboxIcon.tsx:12 from React.ForwardedRef<HTMLDivElement> to React.ForwardedRef<HTMLSpanElement>
  • The component renders a <span> element (line 16) and its props type already correctly specified BaseUIComponentProps<'span', ...> (line 32)
  • This aligns with existing test expectations (refInstanceof: window.HTMLSpanElement in ComboboxIcon.test.tsx:8)
  • Follows the same pattern used by other icon components like SelectIcon that also render <span> elements

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a straightforward type correction that fixes a mismatch between the ref type and the actual rendered element. The fix aligns with existing test expectations, matches the pattern used by similar components, and makes the types consistent across the component definition.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/combobox/icon/ComboboxIcon.tsx Fixed ref type from HTMLDivElement to HTMLSpanElement to match the rendered element and component props type

@greptile-apps

greptile-apps Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@flaviendelangle flaviendelangle changed the title [combobox] Fix the type of the ref [combobox] Fix the type of the ref of theIcon part Jan 20, 2026
@flaviendelangle flaviendelangle changed the title [combobox] Fix the type of the ref of theIcon part [combobox] Fix the type of the ref of the Icon part Jan 20, 2026
/**
* Indicates whether the checkbox item is ticked.
* Renders a `<div>` element.
* Renders a `<span>` element.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I noticed those two other inconsistencies that only impact the JSDoc

@atomiks

atomiks commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

We have a some components the use HTMLElement instead of the exact typing, which most of them use the exact typing (HTMLDivElement, HTMLSpanElement, etc...)

Is there a reason to have this distinction?

Some of my reasoning in this PR #3638. Depends if it's likely to be polymorphic or not. Though for typesafety, the ref can be attached to the rendered element itself anyway: <Button ref={buttonRef} render={<div ref={divRef} />} />

@flaviendelangle

Copy link
Copy Markdown
Member Author

@atomiks thats what I thought, thanks for the confirmation 🙏

@flaviendelangle flaviendelangle merged commit d1a4c6f into mui:master Jan 20, 2026
23 checks passed
@flaviendelangle flaviendelangle deleted the comboboxicon-span branch January 20, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] The ref of Combobox.Icon should take an HTMLSpanElement

3 participants