Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Combobox's current value shall be selected by default in dropdown #820
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed Jun 1, 2017
1 parent 49f4395 commit af23a3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/components/widget/List/RawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RawList extends Component {
componentDidUpdate = prevProps => {
const {
list, mandatory, defaultValue, autofocus, blur, property,
initialFocus
initialFocus, selected
} = this.props;

if(prevProps.blur != blur){
Expand Down Expand Up @@ -53,12 +53,23 @@ class RawList extends Component {

if(list.length > 0) {
this.setState({
dropdownList: dropdown.concat(list),
dropdownList: dropdown.concat(list)
});
}

if(list.length > 0 && !defaultValue) {
this.setState({
selected: list[0]
});
}
}

if(prevProps.selected !== selected){
this.setState({
selected: selected
});
}

const { isOpen } = this.state;

// no need for updating scroll
Expand Down
4 changes: 2 additions & 2 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class App extends Component {

axios.defaults.withCredentials = true;
axios.defaults.headers.common['Content-Type'] = 'application/json';

axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class App extends Component {
const {defaultValue, values} = response.data;
const valuesFlatten = values.map(item => Object.keys(item)[0]);

languageSuccess(valuesFlatten.indexOf(navigator.language) ?
languageSuccess(valuesFlatten.indexOf(navigator.language) ?
navigator.language : defaultValue);
});
}
Expand Down

0 comments on commit af23a3d

Please sign in to comment.