Skip to content

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Dec 24, 2025

When a null item isn't rendered in the list, placeholder acts as a typical placeholder, though it cannot be cleared.

Issues when trying to use a native <label>, which prompted the demos to use Field:

  • Clicking a <label> opens the popup, but this doesn't match native <select> behavior. Trying to workaround this is quite expensive and heavy-handed. On the other hand, <Field.Label> links to the hidden input and only gives focus to the trigger and matches native behavior.
  • Hovering the label activates .Trigger:hover, which unlike Checkbox/Radio, doesn't really look or feel right. <Field.Label> also avoids this.

Select: https://deploy-preview-3604--base-ui.netlify.app/react/components/select
Combobox: https://deploy-preview-3604--base-ui.netlify.app/react/components/combobox#input-inside-popup

@atomiks atomiks added component: select Changes related to the select component. type: new feature Expand the scope of the product to solve a new problem. component: combobox Changes related to the combobox component. labels Dec 24, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 24, 2025

  • vite-css-base-ui-example

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

commit: 951c7ab

@mui-bot
Copy link

mui-bot commented Dec 24, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+830B(+0.20%) 🔺+364B(+0.28%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 951c7ab
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6953b8ed5ec4b2000863ea3b
😎 Deploy Preview https://deploy-preview-3604--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.

@atomiks atomiks force-pushed the feat/combobox-select-placeholder branch from b95e935 to ee223c0 Compare December 24, 2025 02:37
@atomiks atomiks marked this pull request as ready for review December 24, 2025 02:44
@atomiks atomiks force-pushed the feat/combobox-select-placeholder branch 2 times, most recently from c8029dd to 5e4fa02 Compare December 24, 2025 08:39
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Logic looks good, left few comments/questions to be resolved before merging.

*/
listEmpty: boolean;
/**
* Whether the combobox doesn't have a value.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Whether the combobox doesn't have a value.
* Indicates that combobox doesn't have a value.

To read better.

Copy link
Member

Choose a reason for hiding this comment

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

I would rename all state booleans to use this format :D

Copy link
Contributor Author

@atomiks atomiks Dec 28, 2025

Choose a reason for hiding this comment

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

Other boolean state attrs use Whether so I think that's correct for consistency. Indicates on the other hand is used when there is a value alongside the attribute. The CSS vars use "Present when..." for boolean attributes, but that's only because the attribute doesn't exist when false

<Combobox.Positioner>
<Combobox.Popup>
<Combobox.List>
<Combobox.Item value={null}>None</Combobox.Item>
Copy link
Member

Choose a reason for hiding this comment

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

Is this even valid? I mean having items array that difference than the Combobox Items rendered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically yes, this pattern is currently half-broken but is specified throughout the tests. This PR gives it full support: #3594

const items = useStore(store, selectors.items);
const itemToStringLabel = useStore(store, selectors.itemToStringLabel);
const serializedValue = useStore(store, selectors.serializedValue);
const hasSelectedValue = useStore(store, selectors.hasSelectedValue);
Copy link
Member

Choose a reason for hiding this comment

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

There is a lot of repetition here and in the combobox, does it makes sense to extract this in a usePlaceholder hook, or is it too much of an abstraction considering we use different stores? 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think "rule of three" for DRY works here and this is only 2 separate places

@atomiks atomiks force-pushed the feat/combobox-select-placeholder branch 3 times, most recently from c62352e to b0baa48 Compare December 28, 2025 07:44
@atomiks atomiks force-pushed the feat/combobox-select-placeholder branch 3 times, most recently from 39c2f72 to d017b70 Compare December 30, 2025 11:33
@atomiks atomiks force-pushed the feat/combobox-select-placeholder branch from d017b70 to 951c7ab Compare December 30, 2025 11:35
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. component: select Changes related to the select component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants