Skip to content

Conversation

aymeric-giraudet
Copy link
Member

@aymeric-giraudet aymeric-giraudet commented Sep 18, 2025

Summary

FX-3496

Result

Was not too sure how to split components effectively, for now I did :

  • Autocomplete : the wrapper itself, has accessibility attributes taken from the autocomplete library DOM
  • AutocompletePanel: same DOM as for autocomplete
  • AutocompleteIndex: meant for more generic indices, we'll have something special for query suggestions and recent searches

This is still using the internal searchbox implem, not sure if we'll want a custom one or not.

@aymeric-giraudet aymeric-giraudet requested review from a team, dhayab and shaejaz and removed request for a team September 18, 2025 15:39
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6aecadb:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!


return (
<AutocompleteIndex
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we cast it instead?

<AutocompletePanel isOpen={isOpen}>
{indices.map((index) => (
<Index key={index.indexName} indexName={index.indexName}>
<AutocompleteIndexComponent itemComponent={index.itemComponent} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for now, but later once we do keyboard, we likely will want it to be a flat list of indices and use connectAutocomplete? not sure tbh but it likely doesn't change much

Comment on lines 13 to +15
export * from './chat/ChatHeader';
export * from './chat/types';
export * from './autocomplete';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not consistent between chat (no barrel file) and autocomplete (barrel file). I don't have a specific preference, but we'll want to consolidate after both sprints are over.

expect(screen.getByRole('searchbox')).toBeInTheDocument();
await screen.findByText('Item 1');

expect(container.firstChild).toMatchInlineSnapshot(`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a different snapshot for the search box and a separate one for the panel may make sense?


return (
<div className={cx('ais-AutocompleteIndex', classNames.root)}>
<ul className={cx('ais-AutocompleteIndexList', classNames.list)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in hits we use ol, so we should here too.


return (
<div className={cx('ais-AutocompleteIndex', classNames.root)}>
<ul className={cx('ais-AutocompleteIndexList', classNames.list)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there probably (later) should be only one list, as you're navigating across all lists with the keyboard. However there's an argument to be made for separate lists for each index, as that allows us to have header/footer per index.

aria-expanded={isOpen}
aria-haspopup="listbox"
>
{children}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a later iteration (when we do the final dom) we likely want to have the search box be part of this too, and then all the intermediate components also be part of the autocomplete. For now this is a logical split.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants