Skip to content

Commit

Permalink
fix reactjs#287 - checks itemNode is not null in maybeScrollItemIntoView
Browse files Browse the repository at this point in the history
  • Loading branch information
SkinyMonkey committed Nov 2, 2017
1 parent 220044a commit f601a1c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,13 @@ class Autocomplete extends React.Component {
if (this.isOpen() && this.state.highlightedIndex !== null) {
const itemNode = this.refs[`item-${this.state.highlightedIndex}`]
const menuNode = this.refs.menu
scrollIntoView(
findDOMNode(itemNode),
findDOMNode(menuNode),
{ onlyScrollIfNeeded: true }
)
if (itemNode) {
scrollIntoView(
findDOMNode(itemNode),
findDOMNode(menuNode),
{ onlyScrollIfNeeded: true }
)
}
}
}

Expand Down

0 comments on commit f601a1c

Please sign in to comment.