#25715·gutenberg

Autocomplete: Abstract autocomplete to not depend on rich-text package's models

Author: sarayourfriendCreated Sep 29, 2020Updated Sep 28, 2026
Labels[Type] Enhancement[Status] In Progress[Feature] Rich Text[Package] Rich text

Problem

Currently it is very difficult (maybe impossible) to use the Autocomplete component outside of a RichText context. In fact, the example in the documentation for the component does not even work. I'm not exactly sure why this doesn't work, but the way the component is written requires a bunch of stuff from the rich-text package, which seems backwards. My assumption is that something in the components package would be general enough to use outside of any specific WP context.

Solution

Slightly re-write Autocomplete to be more generic (using this example re-write from Jetpack as a starting point) and then create a wrapper around it inside the rich-text package that could be used the way Autocomplete is used today.

Alternative solutions

Make Autocomplete export an adapter interface that translates everything into the rich-text mode, but I think this is more difficult and not as useful as just making the core component generic to begin with.