algolia / docsearch

:blue_book: The easiest way to add search to your documentation.
https://docsearch.algolia.com
MIT License
3.93k stars 381 forks source link

Arrow-up key will cause error when there is no searching items #1057

Closed maoxiaoke closed 2 years ago

maoxiaoke commented 2 years ago

Description

When press the arrow up key,@docsearch/react will mark the page crash. It is worth emphasizing that this's only happens with empty seacrh Items.

Reproduction

Steps

  1. Go to https://micro-frontends.ice.work/
  2. Click on Search
  3. Clear all search items
  4. Then press arrow-up key
  5. See error in console

image

And i found the source code that cause the error:https://github.com/algolia/docsearch/blob/e371f9ac9bc99275af193d39f50214c4ea420d22/packages/docsearch-react/src/DocSearchModal.tsx#L149

Expected behavior

Environment

shortcuts commented 2 years ago

Hi,

Upgrading to the latest version of DocSearch v3 will fix this issue: https://github.com/algolia/docsearch/releases/tag/v3.0.0-alpha.40

Have a nice day!