[Autocomplete] onNewRequest to return an object
See original GitHub issueHi, I am using Material UI Components and they are really helpful. I am using an array of objects as datasource for Autocomplete. When I raises an ‘onNewRequest’ event than it passes the text value rather the object user selects. Can you plz see this.
My DataSource:
var airportsList=[];
this.airports.forEach(function(airport){
airportsList.push({
text: airport.itineraryAirportName[0],
key:airport.id[0],
value: <MenuItem
primaryText={airport.itineraryAirportName[0]}
secondaryText={airport.id[0]}
style={{fontFamily:'caslon, garamond, serif !important'}}
leftIcon={<span style={{border: '1px solid grey'}}
className={countryClass}></span>}
innerDivStyle={{paddingLeft: '50px'}}
/>
})
});
My Component:
PickupAirportChange(t) {
RAFActions.PickupAirportChange(t);
},
UpdateDropAirport(t) {
var selectedAirport = '';
if (t.length > 0) {
for (var i = 0; i < this.props.airports.length; i++) {
if (this.props.airports[i].itineraryAirportName[0] == t) {
selectedAirport = this.props.airports[i];
break;
}
}
}
<div className="col m11 l11 form-input departure-airport mt-15">
<AutoComplete
hintText="Search Airport"
onUpdateInput= {this.PickupAirportChange}
onNewRequest={this.UpdatePickupAirport}
maxSearchResults={10}
dataSource={this.props.airportList}
filter={this.props.fil}
triggerUpdateOnFocus={true}
menuProps={{maxHeight:200,width:'100%'}}
underlineStyle={{display:'none'}}>
</AutoComplete>
</div>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
[Autocomplete] onNewRequest to return an object · Issue #3789
Hi, I am using Material UI Components and they are really helpful. I am using an array of objects as datasource for Autocomplete....
Read more >Developers - [Autocomplete] onNewRequest to return an object -
Hi, I am using Material UI Components and they are really helpful. I am using an array of objects as datasource for Autocomplete....
Read more >How can we call onNewRequest property in onBlur in ...
Currently I am using Material-UI and I am using the onNewRequest property in AutoComplete field but the onNewRequest triggers only ...
Read more >api documentation for material-ui (v0.17.1) - GitHub Pages
onNewRequest (); function material-ui.AutoComplete.defaultProps.onUpdateInput (); number material-ui.AutoComplete.defaultProps.menuCloseDelay; object ...
Read more >Autocomplete API - Material UI - MUI
Name Type Default
options * array
renderInput * func
autoComplete bool false
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m currently getting around this by Stringifying the object, passing that to text and then parsing to grab the fields I need in onNewRequest (hackey, but works for what I need right now). Example (don’t get too hung up on the Ramda stuff - general idea is to stringify the object, then parse when you need to use the object in onNewRequest):
Closed by #4783