From 32d159344854c7fc10d98af631708bab3114d9bc Mon Sep 17 00:00:00 2001 From: yiminghe Date: Fri, 8 Apr 2016 23:51:07 +0800 Subject: [PATCH] add focused className. Fixes #72 --- assets/index.less | 5 +++++ package.json | 2 +- src/Select.jsx | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/assets/index.less b/assets/index.less index 260885350..8e2a0cfee 100644 --- a/assets/index.less +++ b/assets/index.less @@ -58,6 +58,11 @@ border: 1px solid #d9d9d9; } + &-focused &-selection { + border-color: #23c0fa; + box-shadow: 0 0 2px fadeout(#2db7f5, 20%); + } + &-enabled &-selection { &:hover { border-color: #23c0fa; diff --git a/package.json b/package.json index 87c0f2d12..5ffcf9ebf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-select", - "version": "6.0.5", + "version": "6.0.6", "description": "React Select", "keywords": [ "react", diff --git a/src/Select.jsx b/src/Select.jsx index 5c5625d8a..f5298918c 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -104,6 +104,7 @@ const Select = React.createClass({ value, inputValue, open, + focused: false, }; }, @@ -290,6 +291,18 @@ const Select = React.createClass({ this.getInputDOMNode().focus(); }, + onOuterFocus() { + this.setState({ + focused: true, + }); + }, + + onOuterBlur() { + this.setState({ + focused: false, + }); + }, + onClearSelection(event) { const props = this.props; const state = this.state; @@ -594,6 +607,7 @@ const Select = React.createClass({ [className]: !!className, [prefixCls]: 1, [`${prefixCls}-open`]: open, + [`${prefixCls}-focused`]: open || this.state.focused, [`${prefixCls}-combobox`]: isCombobox(props), [`${prefixCls}-disabled`]: disabled, [`${prefixCls}-enabled`]: !disabled, @@ -632,6 +646,8 @@ const Select = React.createClass({ >