diff --git a/src/components/widget/List/RawList.js b/src/components/widget/List/RawList.js index 538948574..ebb794d11 100644 --- a/src/components/widget/List/RawList.js +++ b/src/components/widget/List/RawList.js @@ -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){ @@ -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 diff --git a/src/containers/App.js b/src/containers/App.js index 67c8446f5..0bf174be1 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -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) { @@ -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); }); }