algolia / algolia/autocomplete

TypeError: Cannot read properties of null (onKeyDown.js)

Closed
#1,246 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
341
Avg merge
3d 1h
Merged PRs (30d)
5

Description

## Description

Greetings dear fellows.

We did set up Algolia search autocomplete with the help of `@algolia/autocomplete-js`. It is quite similar to what is defined in the [query suggestions sandbox example](https://codesandbox.io/p/sandbox/github/algolia/autocomplete/tree/next/examples/query-suggestions?file=%2Fapp.tsx) from your docs.

It is rolled out in one of our services and works, however we are noticing cryptic errors coming from the library code.
We cannot reproduce it and it happens quite occasionally.
Sentry gives us the following traceback:

```
TypeError: Cannot read properties of null (reading 'item')
at (./node_modules/@algolia/autocomplete-core/dist/esm/onKeyDown.js:116:20)
at .onKeyDown(./node_modules/@algolia/autocomplete-core/dist/esm/getPropGetters.js:179:9)
at .onKeyDown(./node_modules/@algolia/autocomplete-js/dist/esm/elements/Input.js:36:18)
at eventProxy(./node_modules/@algolia/autocomplete-js/dist/esm/utils/setProperties.js:30:25)
```

## Reproduction

Couldn't yet.

## Expected behavior

No errors coming from the library.

## Environment

- OS: Windows >= 10
- Browser: Edge 122.0.0, Firefox 124.0, Chrome 122.0.0, Edge 120.0.0
- Autocomplete version: 1.17.0

Contributor guide

Open the contributing guide

Research direction

Start by inspecting autocomplete-core/dist/esm/onKeyDown.js around line 116 and trace the onKeyDown flow through getPropGetters.js and autocomplete-js/dist/esm/elements/Input.js. Determine when the selected item is null, then verify the fix against the reported browsers and add regression coverage if the repository provides a relevant test entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.