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(completion): prevent error when getting activeItem with an empty collection #623

Merged
merged 2 commits into from Jul 8, 2021

Conversation

shortcuts
Copy link
Member

Summary

With an empty collections, itemInputValue was undefined which was throwing an error when destructuring it.

Result

  • We now check that itemInputValue exists before returning it, otherwise, we return null.
  • The activeItemId returned was -1, we now return null if there's no items in the collections.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 7, 2021

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 9d55b06:

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-example-starter Configuration
@algolia/autocomplete-example-voice-search Configuration
@algolia/autocomplete-example-vue 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.

these ! are much more dangerous than they seem sometimes, we need some kind of way to avoid them in the code more (same for InstantSearch)

@shortcuts shortcuts merged commit 0e0ce81 into next Jul 8, 2021
@shortcuts shortcuts deleted the fix/completion branch July 8, 2021 08:14
@francoischalifour
Copy link
Member

@Haroenv They are, but to be clear, this wasn't the code responsible for the bug, this was only a refactor. The fix happens in getNextActiveItemId.

@Haroenv
Copy link
Contributor

Haroenv commented Jul 9, 2021

Thanks for the clarification!

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.

None yet

3 participants