<commit_before>import PropTypes from "prop-types"
import React from "react"
import styled from "styled-components"

import List from "./components/List"

const Wrapper = styled.div`
  width: 100%;
  position: relative;
`

class GooglePlacesSuggest extends React.Component {
  constructor(props) {
    super()

    this.state = {
      focusedPredictionIndex: 0,
      predictions: [],
      open: !!props.autocompletionRequest && props.autocompletionRequest.input,
    }

    this.handleKeyDown = this.handleKeyDown.bind(this)
  }

  componentWillMount() {
    this.updatePredictions(this.props.autocompletionRequest)
  }

  componentWillReceiveProps(nextProps) {
    if (
      this.props.autocompletionRequest !== nextProps.autocompletionRequest &&
      nextProps.autocompletionRequest
    ) {
      this.updatePredictions(nextProps.autocompletionRequest)
    }
  }

  handleSelectPrediction(suggest) {
    const {onSelectSuggest} = this.props
    this.setState(
      {
        open: false,
        predictions: [],
      },
      () => {
        this.geocodePrediction(suggest.description, result => {
          onSelectSuggest(result)
        })
      }<commit_msg>issue #20 -  added the suggestion as argument to onSelectSuggest (#21)<commit_after>import PropTypes from "prop-types"
import React from "react"
import styled from "styled-components"

import List from "./components/List"

const Wrapper = styled.div`
  width: 100%;
  position: relative;
`

class GooglePlacesSuggest extends React.Component {
  constructor(props) {
    super()

    this.state = {
      focusedPredictionIndex: 0,
      predictions: [],
      open: !!props.autocompletionRequest && props.autocompletionRequest.input,
    }

    this.handleKeyDown = this.handleKeyDown.bind(this)
  }

  componentWillMount() {
    this.updatePredictions(this.props.autocompletionRequest)
  }

  componentWillReceiveProps(nextProps) {
    if (
      this.props.autocompletionRequest !== nextProps.autocompletionRequest &&
      nextProps.autocompletionRequest
    ) {
      this.updatePredictions(nextProps.autocompletionRequest)
    }
  }

  handleSelectPrediction(suggest) {
    const {onSelectSuggest} = this.props
    this.setState(
      {
        open: false,
        predictions: [],
      },
      () => {
        this.geocodePrediction(suggest.description, result => {
          onSelectSuggest(result, suggest)
        })
      }
{'fraction_non_alphanumeric': 0.10465116279069768, 'fraction_numerical': 0.0049833887043189366, 'mean_word_length': 3.1391752577319587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '172191', 'n_tokens_mistral': 719, 'n_tokens_neox': 690, 'n_words': 124}