From 6d05d71a7cc08f309c139fb225a955ca035a9b42 Mon Sep 17 00:00:00 2001 From: solarjoker Date: Tue, 22 Oct 2019 15:28:59 +0800 Subject: [PATCH] fix: fix #721 --- components/cascader/Cascader.js | 9 +++++---- components/cascader/Menu.js | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/cascader/Cascader.js b/components/cascader/Cascader.js index f23bb7015..ae77280b0 100644 --- a/components/cascader/Cascader.js +++ b/components/cascader/Cascader.js @@ -47,7 +47,7 @@ class Cascader extends Component { const cascaderValue = this.props.value const cacheValue = this.props.value const cascaderLabel = this.getCascaderLabel(cascaderValue) - + this.hiCascader = React.createRef() this.debouncedKeywordChange = debounce(this.onKeywordChange.bind(this), 300) this.clickOutsideHandel = this.clickOutside.bind(this) this.state = { @@ -183,7 +183,7 @@ class Cascader extends Component { } = this.state if (!keyword) { this.setState({ - filterOptions: data + filterOptions: false }) return } @@ -333,9 +333,8 @@ class Cascader extends Component { } const expandIcon = popperShow ? 'icon-up' : 'icon-down' const placeholder = cascaderLabel || this.localeDatasProps('placeholder') - return ( -
+
{ this.inputContainer = node }} onClick={this.handleClick.bind(this)}> { @@ -371,6 +370,8 @@ class Cascader extends Component { value={cascaderValue} options={filterOptions || data} root={() => this} + isFiltered={filterOptions} + filterOptionWidth={this.hiCascader.current && this.hiCascader.current.clientWidth} onSelect={this.onChangeValue.bind(this)} /> diff --git a/components/cascader/Menu.js b/components/cascader/Menu.js index 72d2b8c4b..b70129b54 100644 --- a/components/cascader/Menu.js +++ b/components/cascader/Menu.js @@ -26,7 +26,9 @@ class Menu extends Component { const { value, options, - onSelect + onSelect, + isFiltered, + filterOptionWidth } = this.props const root = this.root() const menus = [] @@ -42,7 +44,7 @@ class Menu extends Component { currentOptions = false menus.push( -
    +
      { _currentOptions.length === 0 &&