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

fix(autocomplete-js): update components with new renderer #946

Merged
merged 12 commits into from
Apr 12, 2022

Conversation

sarahdayan
Copy link
Member

@sarahdayan sarahdayan commented Apr 11, 2022

This fixes an issue where default components aren't updated with the new createElement when updating the renderer with the Update API.

The issue was caused by the fact that user-provided components are merged last (which allows users to override default components with their own). The consequence is that when updating the options, the "old" default components are therefore merged and override the new ones.

The difficulty is that, because users can technically override default components (provide Highlight, Snippet, etc.), we can't just update default components by name. Therefore, this PR identifies default component with an internal property so that we can only update them and leave user components untouched.

In a future major, it would be simpler to disallow registering components with the same name as default components. It would require less code and remove confusion without removing any important capabilities.

Since this PR was about components, I also implemented the final unimplemented tests.

fixes #934

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 11, 2022

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 c62ac1e:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
algolia/autocomplete Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

@sarahdayan sarahdayan marked this pull request as ready for review April 11, 2022 20:55
Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

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

Nitpicky suggestion

packages/autocomplete-js/src/utils/pickBy.ts Show resolved Hide resolved
@sarahdayan sarahdayan merged commit 8fa038b into next Apr 12, 2022
@sarahdayan sarahdayan deleted the fix/components-renderer branch April 12, 2022 11:10
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.

Update components when renderer is updated
3 participants