import React, { PropTypes } from 'react' import ReactDOM from 'react-dom' import ModeIcon from 'browser/components/ModeIcon' import { selectArticle } from './actions' export default class FinderList extends React.Component { componentDidUpdate () { var index = this.props.articles.indexOf(this.props.activeArticle) var el = ReactDOM.findDOMNode(this) var li = el.querySelectorAll('li')[index] if (li == null) { return } var overflowBelow = el.clientHeight + el.scrollTop < li.offsetTop + li.clientHeight if (overflowBelow) { el.scrollTop = li.offsetTop + li.clientHeight - el.clientHeight } var overflowAbove = el.scrollTop > li.offsetTop if (overflowAbove) { el.scrollTop = li.offsetTop } } handleArticleClick (article) { return (e) => { let { dispatch } = this.props dispatch(selectArticle(article.key)) } } render () { let articleElements = this.props.articles.map(function (article) { if (article == null) { return (
  • Undefined
  • ) } var isActive = this.props.activeArticle != null && (article.key === this.props.activeArticle.key) return (
  • {article.title}
  • ) }.bind(this)) return (
    ) } } FinderList.propTypes = { articles: PropTypes.array, activeArticle: PropTypes.shape({ type: PropTypes.string, key: PropTypes.string }), dispatch: PropTypes.func }