Skip to content
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

[Autocomplete] Refactor useAutocomplete to use Base UI building blocks #45

Closed
6 tasks
michaldudak opened this issue Aug 30, 2023 · 8 comments
Closed
6 tasks
Assignees
Labels
component: autocomplete This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@michaldudak
Copy link
Member

michaldudak commented Aug 30, 2023

The useAutocomplete hook was created before Base UI existed and has code patterns different from the rest of the hooks in the library. Additionally, it does not use the lower-level building blocks from Base UI (like useList) but implements its whole functionality by itself. Reusing the same building blocks as other components could help us reduce the overall bundle size and have feature parity with the Select (where applicable).
There are a number of issues reported that could be solved by replacing the implementation.

Areas of improvement:

  • Use useList instead of reimplementing keyboard navigation
  • Convert the code and tests to TypeScript
  • Do not set any classes (it's a responsibility of a component, not a hook)
  • Accept external props in get*Props functions
  • Implement a reducer to handle state and expose its dispatch function to allow programmatic control
  • Revise prop naming (like freeSolo)

Issues that could be solved along the way:

Since this will likely be a breaking change, we should leave the current version intact (but deprecate it and remove it in the future).

@michaldudak michaldudak self-assigned this Aug 30, 2023
@sai6855
Copy link
Contributor

sai6855 commented Sep 1, 2023

Since useList is going to use in Select, Menu, Autocomplete (In future). does it makes sense to add Infinite scroll feature in useList itself (as it's one of most requested feature)? Once it is implemented in useList, Autocomplete just need to pass necessary props to make it working.

@michaldudak
Copy link
Member Author

I don't think components other than Autocomplete would make use of infinite scroll, so we need to be careful not to include features that won't be used but will increase the component size. I think we can add an event to the List fired when scroll is near the bottom.

@marcpachecog
Copy link
Contributor

@michaldudak Infinite scrolling inside a list is in fact a very common feature rather than not, I have it implemented on my own by using the Intersection Observer. So it make sense to also add it to the List as you mentioned.

@mj12albert
Copy link
Member

I've opened an issue to organize the scope of Autocomplete for material-next: mui/material-ui#39963

I think at a minimum we can convert to TS

@michaldudak michaldudak transferred this issue from mui/material-ui Feb 27, 2024
@michaldudak michaldudak changed the title [Autocomplete][base-ui] Refactor useAutocomplete to use Base UI building blocks [Autocomplete] Refactor useAutocomplete to use Base UI building blocks Feb 27, 2024
@michaldudak michaldudak added component: autocomplete This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature labels Feb 27, 2024
@lhilgert9
Copy link

@michaldudak Hey, I would like to work on the useAutocomplete hook and convert it to typescript, if that would be ok?

@michaldudak
Copy link
Member Author

There's no point in doing this now. We plan to create the new Autocomplete/Combobox component in Base UI and use it in Material UI.

@michaldudak
Copy link
Member Author

Superseded by #222

@michaldudak michaldudak closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Base UI Alpha Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
Archived in project
Development

No branches or pull requests

5 participants