mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 13:06:03 +10:00
Use Input component in LocationAutocompleteInput
This commit is contained in:
parent
9ce53a1393
commit
4341cd629d
1 changed files with 6 additions and 7 deletions
|
|
@ -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 (
|
||||
<div className={css.root}>
|
||||
<input
|
||||
<Input
|
||||
className={classNames(css.input, className)}
|
||||
type="search"
|
||||
autoComplete="off"
|
||||
|
|
@ -305,9 +307,6 @@ class LocationAutocompleteInput extends Component {
|
|||
onBlur={handleOnBlur}
|
||||
onChange={this.onChange}
|
||||
onKeyDown={this.onKeyDown}
|
||||
ref={i => {
|
||||
this.input = i;
|
||||
}}
|
||||
/>
|
||||
{renderPredictions
|
||||
? <div
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue