From 819df272bd9964937e83720c20de3ef440ea129f Mon Sep 17 00:00:00 2001 From: Leon Shi Date: Tue, 26 Apr 2016 17:06:50 +0800 Subject: [PATCH 1/2] fix error on click placeholder when `showSearch` is set to `false`, close #79 --- src/Select.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Select.jsx b/src/Select.jsx index 697060e7f..d92dd5246 100644 --- a/src/Select.jsx +++ b/src/Select.jsx @@ -276,7 +276,9 @@ const Select = React.createClass({ }, onPlaceholderClick() { - this.getInputDOMNode().focus(); + if (this.props.showSearch) { + this.getInputDOMNode().focus(); + } }, onOuterFocus() { From d22d4ac1f18edf0bf43dee81e51488def29e429d Mon Sep 17 00:00:00 2001 From: Leon Shi Date: Tue, 26 Apr 2016 17:09:03 +0800 Subject: [PATCH 2/2] add single demo without search --- examples/single-without-search.html | 1 + examples/single-without-search.js | 97 +++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 examples/single-without-search.html create mode 100644 examples/single-without-search.js diff --git a/examples/single-without-search.html b/examples/single-without-search.html new file mode 100644 index 000000000..b3a425249 --- /dev/null +++ b/examples/single-without-search.html @@ -0,0 +1 @@ +placeholder \ No newline at end of file diff --git a/examples/single-without-search.js b/examples/single-without-search.js new file mode 100644 index 000000000..70a2b6c04 --- /dev/null +++ b/examples/single-without-search.js @@ -0,0 +1,97 @@ +/* eslint no-console: 0 */ + +import React from 'react'; +import Select, { Option } from 'rc-select'; +import 'rc-select/assets/index.less'; +import ReactDOM from 'react-dom'; + +const Test = React.createClass({ + getInitialState() { + return { + destroy: false, + value: String(9), + }; + }, + + onChange(e) { + let value; + if (e && e.target) { + value = e.target.value; + } else { + value = e; + } + this.setState({ + value, + }); + }, + + onDestroy() { + this.setState({ + destroy: 1, + }); + }, + + render() { + if (this.state.destroy) { + return null; + } + return ( +
+
+ +

Single Select without search

+ +
+ +
+ +

native select

+ + +

+ +

+
+ ); + }, +}); + +ReactDOM.render(, document.getElementById('__react-content'));