Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value on autocomplete not changing when state updated #7312

Closed
soroushm opened this issue Jul 1, 2017 · 2 comments
Closed

value on autocomplete not changing when state updated #7312

soroushm opened this issue Jul 1, 2017 · 2 comments
Labels
component: autocomplete This is the name of the generic UI component, not the React module! v0.x

Comments

@soroushm
Copy link

soroushm commented Jul 1, 2017

Application have two autoComplete (From and To)
screen shot 2017-07-01 at 7 22 03 pm

after click on toggle button i will toggle state from and to

  toggleTarget() {
    let from = this.state.From
    let to = this.state.To
    console.log('toggleTarget', from, to)
    this.setState({
      From: to,
      To: from
    })
  }

actually state will be change but value of input not changing
screen shot 2017-07-01 at 7 26 54 pm

auto Complete code

<div className="row">
              <div className="col-xs-5">
                <AutoComplete
                  name="From"
                  Value={this.state.From}
                  onUpdateInput={this.changeFrom}
                  openOnFocus={true}
                  hintText={t('From')}
                  ref="From"
                  dataSource={this.flights}
                  dataSourceConfig={{
                    text: 'name',
                    value: 'code'
                  }}
                />
              </div>
              <div className="col-xs-2  text-center">
                <FontIcon onClick={this.toggleTarget} style={iconStyles}
                          className="material-icons">swap_horiz</FontIcon>
              </div>
              <div className="col-xs-5">
                <AutoComplete
                  hintText={t('To')}
                  ref="To"
                  onUpdateInput={this.changeTo}
                  dataSource={this.flights}
                  dataSourceConfig={{
                    text: 'name',
                    value: 'code'
                  }}
                  name="To"
                  value={this.state.To}
                />
              </div>
              </div>

How can change value of input ?

@soroushm soroushm changed the title value on autocomplete not changing when state will be update value on autocomplete not changing when state updated Jul 1, 2017
@slavab89
Copy link
Contributor

Please check the doc site http://www.material-ui.com/#/components/auto-complete
There is no value prop on AutoComplete. You might need to use searchText to control the text that is shown.

@oliviertassinari
Copy link
Member

Closed by #4783

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! v0.x
Projects
None yet
Development

No branches or pull requests

3 participants