Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #1

Merged
merged 17 commits into from
May 25, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix anim
  • Loading branch information
yiminghe committed Apr 18, 2016
commit 0596f8d9be0656d1c61aee95361188f99ad7be85
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-select",
"version": "6.1.0",
"version": "6.1.1",
"description": "React Select",
"keywords": [
"react",
@@ -45,12 +45,13 @@
"querystring": "^0.2.0",
"rc-dialog": "^5.3.1",
"rc-tools": "5.x",
"react": "~0.14.0",
"react-addons-test-utils": "~0.14.0",
"react-dom": "~0.14.0"
"react": "15.x",
"react-addons-test-utils": "15.x",
"react-dom": "15.x"
},
"dependencies": {
"classnames": "2.x",
"component-classes": "1.x",
"dom-scroll-into-view": "1.x",
"rc-animate": "2.x",
"rc-menu": "4.x",
77 changes: 44 additions & 33 deletions src/Select.jsx
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import { KeyCode } from 'rc-util';
import classnames from 'classnames';
import OptGroup from './OptGroup';
import Animate from 'rc-animate';
import classes from 'component-classes';
import {
getPropValue, getValuePropValue, isCombobox,
isMultipleOrTags, isMultipleOrTagsOrCombobox,
@@ -104,7 +105,6 @@ const Select = React.createClass({
value,
inputValue,
open,
focused: false,
};
},

@@ -124,8 +124,7 @@ const Select = React.createClass({
},

componentDidUpdate() {
const state = this.state;
const props = this.props;
const { state, props } = this;
if (state.open && (isMultipleOrTags(props) || props.showSearch)) {
const inputNode = this.getInputDOMNode();
if (inputNode.value) {
@@ -162,7 +161,6 @@ const Select = React.createClass({
},

onDropdownVisibleChange(open) {
// debugger
// selection inside combobox cause click
if (!open && document.activeElement === this.getInputDOMNode()) {
return;
@@ -293,15 +291,13 @@ const Select = React.createClass({
},

onOuterFocus() {
this.setState({
focused: true,
});
this._focused = true;
this.updateFocusClassName();
},

onOuterBlur() {
this.setState({
focused: false,
});
this._focused = false;
this.updateFocusClassName();
},

onClearSelection(event) {
@@ -430,31 +426,45 @@ const Select = React.createClass({

setOpenState(open, needFocus) {
this.clearDelayTimer();
const { props, refs } = this;
// can not optimize, if children is empty
// if (this.state.open === open) {
// return;
// }
this.setState({
const { props, state } = this;
if (state.open === open) {
this.afterOpen(open, needFocus);
return;
}
const nextState = {
open,
}, () => {
if (needFocus || open) {
if (open || isMultipleOrTagsOrCombobox(props)) {
const input = this.getInputDOMNode();
if (input && document.activeElement !== input) {
input.focus();
}
} else if (refs.selection) {
refs.selection.focus();
};
// clear search input value when open is false in singleMode.
if (!open && isSingleMode(props) && props.showSearch) {
nextState.inputValue = '';
}
this.setState(nextState, () => {
this.afterOpen(open, needFocus);
});
},

updateFocusClassName() {
const { refs, props } = this;
// avoid setState and its side effect
if (this._focused || this.state.open) {
classes(refs.root).add(`${props.prefixCls}-focused`);
} else {
classes(refs.root).remove(`${props.prefixCls}-focused`);
}
},

afterOpen(open, needFocus) {
const { props, refs } = this;
if (needFocus || open) {
if (open || isMultipleOrTagsOrCombobox(props)) {
const input = this.getInputDOMNode();
if (input && document.activeElement !== input) {
input.focus();
}
} else if (refs.selection) {
refs.selection.focus();
}
// clear search input value when open is false in singleMode.
if (!open && isSingleMode(this.props) && this.props.showSearch) {
this.setState({
inputValue: '',
});
}
});
}
},

addLabelToValue(props, value_) {
@@ -632,7 +642,7 @@ const Select = React.createClass({
[className]: !!className,
[prefixCls]: 1,
[`${prefixCls}-open`]: open,
[`${prefixCls}-focused`]: open || this.state.focused,
[`${prefixCls}-focused`]: open || !!this._focused,
[`${prefixCls}-combobox`]: isCombobox(props),
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-enabled`]: !disabled,
@@ -670,6 +680,7 @@ const Select = React.createClass({
>
<div
style={props.style}
ref="root"
onBlur={this.onOuterBlur}
onFocus={this.onOuterFocus}
className={classnames(rootCls)}
2 changes: 1 addition & 1 deletion src/SelectTrigger.jsx
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ const SelectTrigger = React.createClass({
visible,
});
return (<Trigger {...props}
action={props.disabled ? [] : ['click']}
showAction={props.disabled ? [] : ['click']}
hideAction={props.disabled ? [] : ['blur']}
ref="trigger"
popupPlacement="bottomLeft"