Skip to content

Commit

Permalink
#1180 Autocomplete fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmartin committed Sep 24, 2021
1 parent 00e4df4 commit a9786ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/interface/VFBCircuitBrowser/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class AutocompleteResults extends Component {
super(props);
this.state = { filteredResults: {} };
this.handleResults = this.handleResults.bind(this);
this.fieldLabel = this.props.field.label;
}

/**
Expand All @@ -164,6 +165,11 @@ class AutocompleteResults extends Component {
return this.state.filteredResults;
}

shouldComponentUpdate(nextProps, nextState) {
this.fieldLabel = nextProps.getLatestNeuronFields()[this.props.index].label;
return true;
}

render () {
const label = "Neuron " + (this.props.index + 1) .toString();
const options = Object.keys(this.state.filteredResults).map(option => this.state.filteredResults[option].label);
Expand All @@ -175,7 +181,7 @@ class AutocompleteResults extends Component {
disableClearable
disablePortal
autoHighlight
value={this.props.field.label}
value={this.fieldLabel}
id={this.props.index.toString()}
ListboxProps={{ style: { maxHeight: "10rem" } }}
onChange={this.props.resultSelectedChanged}
Expand Down Expand Up @@ -493,6 +499,7 @@ class Controls extends Component {
field={field}
index={index}
neuronTextfieldModified={this.neuronTextfieldModified}
getLatestNeuronFields={this.getUpdatedNeuronFields}
resultSelectedChanged={(event, value) => this.resultSelectedChanged(event, value, index)}
ref={this.autocompleteRef[index.toString()]}
/>
Expand Down

0 comments on commit a9786ac

Please sign in to comment.