Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Unhelpful error message when the currently highlighted item is not in the array returned by getFilteredItems() #143

@carlpaten

Description

@carlpaten

Using react-autocomplete 1.0.1, React 15.2.1.

When hovering the mouse pointer over any entry in Autocomplete's dropdown list, my application crashes with the following error message and stack trace:

0x800a138f - JavaScript runtime error: Unable to get property 'ownerDocument' of undefined or null reference

    getClientPosition [util.js] Line 5  TypeScript
    getOffset [util.js] Line 68 TypeScript
    module.exports.offset [util.js] Line 370    TypeScript
    scrollIntoView [dom-scroll-into-view.js] Line 18    TypeScript
    maybeScrollItemIntoView [Autocomplete.js] Line 88   TypeScript
    componentDidUpdate [Autocomplete.js] Line 81    TypeScript
    invokeComponentDidUpdateWithTimer [react.js] Line 5746  Script
    ...

Autocomplete.componentDidUpdate gets called by React, and calls this.maybeScrollItemIntoView. this.refs is not populated (it only has the fields input and menu), so this.refs['item-' + this.state.highlightedIndex] becomes undefined and gets passed down. getClientPosition tries to use it, and triggers a crash.

I'm not super familiar with string refs, so I'm not sure what the issue is.

If this doesn't immediately ring a bell, I'll try to put together a minimal repro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions