diff --git a/scripts/server/server.js b/scripts/server/server.js index 8f824fdd00..8ad040fedd 100644 --- a/scripts/server/server.js +++ b/scripts/server/server.js @@ -75,7 +75,7 @@ function run(port) { }); const url = `http://${host}:${port}/${componentName}`; - logger.warn(`Start server, listen to ${url}.`); + logger.warn(`Start server, listen to ${url}`); const server = new WebpackDevServer(compiler, { disableHostCheck: true, diff --git a/src/select/select.jsx b/src/select/select.jsx index a35bc1c522..99b3d4063e 100644 --- a/src/select/select.jsx +++ b/src/select/select.jsx @@ -222,8 +222,10 @@ class Select extends Base { if ('value' in nextProps) { // under controll this.valueDataSource = getValueDataSource(nextProps.value, this.valueDataSource.mapValueDS, this.dataStore.getMapDS()); - } else if ('defaultValue' in nextProps && (nextProps.children !== this.props.children || nextProps.dataSource !== this.props.dataSource)) { - //has defaultValue and dataSource changed + } else if ('defaultValue' in nextProps && + nextProps.defaultValue === this.valueDataSource.value && + (nextProps.children !== this.props.children || nextProps.dataSource !== this.props.dataSource)) { + //has defaultValue and value not changed and dataSource changed this.valueDataSource = getValueDataSource(nextProps.defaultValue, this.valueDataSource.mapValueDS, this.dataStore.getMapDS()); } @@ -620,7 +622,7 @@ class Select extends Base { // because of can not close Popup by click Input while hasSearch. // so when Popup open and hasSearch, we should close Popup intentionally - this.state.visible && this.hasSearch() && this.setVisible(!this.state.visible); + this.state.visible && this.hasSearch() && this.setVisible(false); } handleClear = e => { diff --git a/test/select/index-spec.js b/test/select/index-spec.js index 8afd47eb0d..1cc0b9065e 100644 --- a/test/select/index-spec.js +++ b/test/select/index-spec.js @@ -83,6 +83,31 @@ describe('Select', () => { assert(wrapper.find('.next-select em').text() === 'TT2'); }); + it('should change display text while choose item and change dataSource', () => { + const dataSource = ['abc', 'bbb']; + class App extends React.Component { + render() { + return ( +