Skip to content

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

Description

@michaldudak

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).

Metadata

Metadata

Assignees

Labels

type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

Status
Recently completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions