Cleanup autocomplete

This commit is contained in:
Aviral Dasgupta 2016-08-23 00:36:31 +05:30
parent e173900808
commit 884abbd7e9
8 changed files with 28 additions and 24 deletions

View file

@ -105,7 +105,8 @@ export default class Autocomplete extends React.Component {
// this is the selected completion, so scroll it into view if needed
const selectedCompletion = this.refs[`completion${this.state.selectionOffset}`];
if (selectedCompletion && this.container) {
const {offsetTop} = ReactDOM.findDOMNode(selectedCompletion);
const domNode = ReactDOM.findDOMNode(selectedCompletion);
const offsetTop = domNode && domNode.offsetTop;
if (offsetTop > this.container.scrollTop + this.container.offsetHeight ||
offsetTop < this.container.scrollTop) {
this.container.scrollTop = offsetTop - this.container.offsetTop;