-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[docs][Base] useAutocomplete demos & docs #37029
Conversation
Netlify deploy previewBundle size report |
225c441
to
28c1349
Compare
c3d04ea
to
eda6e76
Compare
9a24231
to
d318db4
Compare
bcf42e7
to
9078bdf
Compare
|
||
{{"demo": "UseAutocompletePopper.js", "hideToolbar": true}} | ||
|
||
{{"demo": ""}} |
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.
This is a weird workaround for this:
.slice(i, rendered.length - 1)`
which I suppose is to hide the old API docs links section, but here it's just cutting off my content as there's no component:
in the markdown front matter 😅
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.
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.
Actualy the reason why it is cut-off is because the components
header is empty, so the API section is not added. Let's instead change the logic in MarkdownDocsV2.js to do the slice only if the headers.components.length > 0
. Please validate if I am correct in this assumption :)
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.
Thanks for picking this up. Few thoughts:
- I believe we should make all demos customized, similar to how the first one is done
Not related to this PR:
- the groupedOptions should probably be just called options. when there is no need for groups the name is misleading
const options = ['The Godfather', 'Pulp Fiction']; | ||
``` | ||
|
||
If you need to use a different struction for options, you must provide a function to the `getOptionLabel` prop that resolves each option to a unique value. |
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 modified this bit compared to the other docs (Material, Joy) because it kind of understates the importance of getOptionLabel
.
The API docs just say “Used to determine the string value for a given option”, but it seems the hook heavily relies on getOptionLabel
to tell different options from each other
I noticed issues kind of related to this:
9078bdf
to
5b49eb8
Compare
:::warning | ||
Material UI and Joy UI have Autocomplete components that are built using the useAutocomplete hook, with many features that are not demo-ed here yet. | ||
|
||
To learn more about implementing a custom Autocomplete, you can explore the useAutocomplete API [docs](/base/react-autocomplete/hooks-api/), or reference the Material UI and Joy UI implementations: | ||
|
||
- [Material UI Autocomplete](/material-ui/react-autocomplete/) | ||
- [Joy UI Autocomplete](/joy-ui/react-autocomplete/) | ||
|
||
::: |
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.
@samuelsycamore I think the message in this callout is a little clumsy, any suggestions? 😅
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.
Looks pretty good to me! Here's how I'd phrase that first part.
:::warning | |
Material UI and Joy UI have Autocomplete components that are built using the useAutocomplete hook, with many features that are not demo-ed here yet. | |
To learn more about implementing a custom Autocomplete, you can explore the useAutocomplete API [docs](/base/react-autocomplete/hooks-api/), or reference the Material UI and Joy UI implementations: | |
- [Material UI Autocomplete](/material-ui/react-autocomplete/) | |
- [Joy UI Autocomplete](/joy-ui/react-autocomplete/) | |
::: | |
:::warning | |
Material UI and Joy UI have Autocomplete components that are built using the `useAutocomplete` hook, and they include many features not yet described here. | |
To learn more about implementing a custom Autocomplete, you can explore the [`useAutocomplete` API docs](/base/react-autocomplete/hooks-api/), or reference the Material UI and Joy UI implementations: | |
- [Material UI Autocomplete](/material-ui/react-autocomplete/) | |
- [Joy UI Autocomplete](/joy-ui/react-autocomplete/) | |
::: |
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.
Looks great!
docs/data/base/components/autocomplete/AutocompleteIntroduction.tsx
Outdated
Show resolved
Hide resolved
docs/data/base/components/autocomplete/AutocompleteIntroduction.tsx
Outdated
Show resolved
Hide resolved
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.
Only one comment left, the rest looks great
|
||
{{"demo": "UseAutocompletePopper.js", "hideToolbar": true}} | ||
|
||
{{"demo": ""}} |
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.
Actualy the reason why it is cut-off is because the components
header is empty, so the API section is not added. Let's instead change the logic in MarkdownDocsV2.js to do the slice only if the headers.components.length > 0
. Please validate if I am correct in this assumption :)
33c3e30
to
0228d28
Compare
This worked and I added a comment! @mnajdova |
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.
Just left two comments. Looks good. Let's ship it!
docs/data/base/components/autocomplete/UseAutocompletePopper.tsx
Outdated
Show resolved
Hide resolved
d6f90f1
to
55576c1
Compare
55576c1
to
ecada5c
Compare
Resolves #36884
Resolves #37252
Preview: https://deploy-preview-37029--material-ui.netlify.app/base/react-autocomplete/
Adding some demos to show how to use
useAutocomplete
. There is no Autocomplete component yet, just the hook.Demos
In this PR I'm aiming to add the minimal amount of topics to cover the most basic use-cases of
useAutocomplete
, and will exclude big topics such asfreeSolo
ormulti
.