From 4341cd629da31803fae9ede6d34a3f50b1c6891d Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 29 Mar 2017 11:09:48 +0300 Subject: [PATCH] Use Input component in LocationAutocompleteInput --- .../LocationAutocompleteInput.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/LocationAutocompleteInput/LocationAutocompleteInput.js b/src/components/LocationAutocompleteInput/LocationAutocompleteInput.js index 4129fa78..bfb7ef86 100644 --- a/src/components/LocationAutocompleteInput/LocationAutocompleteInput.js +++ b/src/components/LocationAutocompleteInput/LocationAutocompleteInput.js @@ -1,6 +1,7 @@ import React, { Component, PropTypes } from 'react'; import { debounce } from 'lodash'; import classNames from 'classnames'; +import { Input } from '../../components'; import * as propTypes from '../../util/propTypes'; import { getPlacePredictions, getPlaceDetails } from '../../util/googleMaps'; @@ -64,7 +65,8 @@ LocationPredictionsList.propTypes = { // LocationAutocompleteInput props. const currentValue = props => { const value = props.input.value || {}; - return { search: '', predictions: [], selectedPlaceId: null, selectedPlace: null, ...value }; + const { search = '', predictions = [], selectedPlaceId = null, selectedPlace = null } = value; + return { search, predictions, selectedPlaceId, selectedPlace }; }; /* @@ -135,10 +137,10 @@ class LocationAutocompleteInput extends Component { } // Handle input text change, fetch predictions if the value isn't empty - onChange() { + onChange(e) { const onChange = this.props.input.onChange; const { predictions } = currentValue(this.props); - const newValue = this.input.value; + const newValue = e.target.value; // Clear the current values since the input content is changed onChange({ @@ -294,7 +296,7 @@ class LocationAutocompleteInput extends Component { return (
- { - this.input = i; - }} /> {renderPredictions ?