-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CustomSelectControl: refactor using ariakit #41726
CustomSelectControl: refactor using ariakit #41726
Conversation
Size Change: +44 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
|
||
// TODO: | ||
// - should we use 'select' instead of `div` for props inheritance? | ||
// - should we allow polymorphism ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't really expect CustomSelectControlProps
to inherit from HTMLSelectElement
at all since it's completely custom and doesn't ultimately render a <select>
, no? That is, I'd expect props
to have type SelectControlProps
and not WordPressComponentProps< SelectControlProps, 'select', false >
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't really expect
CustomSelectControlProps
to inherit fromHTMLSelectElement
at all since it's completely custom and doesn't ultimately render a<select>
, no?
This in an interesting one. On one end, we should aim at CustomSelectControlProps
to be semantically a replacement for the select
HTML element — on the other end, it's not going to be easy to support all props/functionality of the native select
HTML element.
For example, Ariakit
doesn't seem to support all of those props either:
That is, I'd expect props to have type SelectControlProps and not WordPressComponentProps< SelectControlProps, 'select', false >.
By default, components in the package should use the WordPressComponentProps
type utility unless there's a good reason for them not to. At most, if we wanted to keep it as general as possible, we could type the props as WordPressComponentProps< SelectControlProps, 'div', false >
1ecba05
to
213d63e
Compare
213d63e
to
43e9559
Compare
Yup! |
What?
Related to #41466
Related to #41430 (comment)
Related to #43475
Likely superseeds #37272
This PR attempts to refactor the
CustomSelectControl
component using theSelect
components fromariakit
Why?
Using
ariakit
under the hood will allow us to:ariakit
libraryselect
elementSee #41466 for more details.
How?
ariakit
options
vs passingchildren
) (also see this comment)CustomSelectControl
componentonHighlightedIndexChange
or similar proprenderItem
prop?)options
prop?)CustomSelectControl
from old to new componentTesting Instructions
TBD
Screenshots or screencast
TBD