Skip to content

Commit

Permalink
fix combobox menu select
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Nov 29, 2016
1 parent 6ec4090 commit 579f4d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-select",
"version": "6.6.8",
"version": "6.6.9",
"description": "React Select",
"keywords": [
"react",
Expand Down
17 changes: 17 additions & 0 deletions src/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const Select = React.createClass({

componentWillUnmount() {
this.clearBlurTime();
this.clearAdjustTimer();
if (this.dropdownContainer) {
ReactDOM.unmountComponentAtNode(this.dropdownContainer);
document.body.removeChild(this.dropdownContainer);
Expand Down Expand Up @@ -290,6 +291,13 @@ const Select = React.createClass({
title: selectedTitle,
}]);
} else {
if (isCombobox(props)) {
this.skipAdjustOpen = true;
this.clearAdjustTimer();
this.skipAdjustOpenTimer = setTimeout(() => {
this.skipAdjustOpen = false;
}, 0);
}

This comment has been minimized.

Copy link
@afc163

afc163 Jul 17, 2017

Member

这块的实现有点看不懂。这种方式没能解决这样的问题:ant-design/ant-design#6600

if (value.length && value[0].key === selectedValue) {
this.setOpenState(false, true);
return;
Expand Down Expand Up @@ -568,6 +576,12 @@ const Select = React.createClass({
this.blurTimer = null;
}
},
clearAdjustTimer() {
if (this.skipAdjustOpenTimer) {
clearTimeout(this.skipAdjustOpenTimer);
this.skipAdjustOpenTimer = null;
}
},
updateFocusClassName() {
const { refs, props } = this;
// avoid setState and its side effect
Expand Down Expand Up @@ -700,6 +714,9 @@ const Select = React.createClass({
},

adjustOpenState() {
if (this.skipAdjustOpen) {
return;
}
let { open } = this.state;
if (typeof document !== 'undefined' &&
this.getInputDOMNode() &&
Expand Down

0 comments on commit 579f4d4

Please sign in to comment.