-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components: explore using ariakit
's Select
component to implement SelectControl
& related
#41466
Comments
Summarising some of the thoughts I remember having during our conversation at WCEU 😀
Personally I think it's nice to use a
I think this all makes sense. We already have a need for it: #41430. I don't know that we should allow too much customisation, though. For example ariakit exports
I'm on the fence about this one. I do like that right now you can pass whatever you get from |
Thank you for summarizing our conversations here!
This is definitely a good point, and one that I don't have a definitive answer to for now. I'd like to explore both options (and potentially more alternatives) in the upcoming weeks. I'll probably start by trying to use
Re. the amount of customisation, I partially replied to this point in #41430 (comment). Re. the specific
Does the data retrieved from Another reason for deprecating Of course, we'd need to support both approaches ( |
I guess what I had in mind is that you give a list of objects to the component and it doesn't really matter what that object is because what happens is completely up to You're right that some mapping is probably inevitable. I'm with you on transitioning to |
As a matter of curiosity, Ariakit does render a native I'd keep |
One thing I noticed while working on #43230 is that the current implementation of CustomSelectControl renders its options popover within the component's root wrapper div, instead of a separate popover slot. This means the popover is constrained by the width of the CustomSelectControl's container, as seen in this usage within a grid: This isn't ideal, since a popover should be able to grow its width wider to the edge of the viewport. Something to keep in mind when rewriting the component. |
Just noting that in #44966 I added an |
Currently, there a few components in the
@wordpress/components
package that build onto / expand the vanilla HTMLselect
element:SelectControl
CustomSelectControl
ComboboxControl
FormTokenField
The goal is explore the feasibility of rewriting some, or all of these components using
ariakit
'sSelect
component` under the hoodUseful links:
ariakit
examples:Select
Select
autofillSelect
comboboxSelect
gridSelect
groupSelect
custom itemSelect
multiple selectionNotes so far:
ariakit
'sSelect
doesn't seem to use a nativeselect
element under the hood — this means that current usages ofSelectControl
where vanillaoption
andoptiongroup
elements are being passed aschildren
will not work. This would potentially be a breaking change; to cope with it, we could either keep both the new version and the old version of the component around while we soft deprecate this type of usage, or we could look into a way to automatically detect and "convert" the vanilla HTML elements to theariakit
equivalentsariakit
adopts a modular approach to how components are exported (SelectItem
,SelectGroup
,SelectGroupLabel
,SelectSeparator
). If we want to give our customers the freedom of specifying a custom select item layout, we may have to basically re-export each of these components (while adding some custom styles on top). Not necessarily a bad thing per se, but we should be aware of this shift in the APIs.SelectControl
andCustomSelectControl
would practically have the same underlying implementationSelectControl
andCustomSelectControl
component don't have a way to customize the look of the dropdown itself — should we consider adding adding a "renderValue" prop, used to render aSelectItem
both as the dropdown selected item, and each option? (for reference, see therenderValue
function in this example)ariakit
'sSelect
component uses internallyariakit
'sPopover
— we may ultimately want to switch to that implementation, for consistency and efficiency's sakeTODO:
The text was updated successfully, but these errors were encountered: