Skip to content

Commit 0a48690

Browse files
Add searchable option to Select component so it can better be used on mobile
1 parent f641de1 commit 0a48690

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

react/components/EXPERIMENTAL_Select/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,33 @@ const options = [
272272
</div>
273273
```
274274

275+
Without search input (good for mobile experience)
276+
277+
```js
278+
const options = [
279+
{
280+
value: 'first-option',
281+
label: 'First Option',
282+
},
283+
{
284+
value: 'second-option',
285+
label: 'Second Option',
286+
},
287+
]
288+
289+
;<div>
290+
<Select
291+
label="Label"
292+
options={options}
293+
multi={false}
294+
searchable={false}
295+
onChange={values => {
296+
console.log(`[Select] Selected: ${JSON.stringify(values, null, 2)}`)
297+
}}
298+
/>
299+
</div>
300+
```
301+
275302
Loading state
276303

277304
```js

react/components/EXPERIMENTAL_Select/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Select extends Component {
4141
formatCreateLabel,
4242
label,
4343
loading,
44+
searchable,
4445
multi,
4546
noOptionsMessage,
4647
onChange,
@@ -80,6 +81,7 @@ class Select extends Component {
8081
isClearable: clearable,
8182
isDisabled: disabled,
8283
isLoading: loading,
84+
isSearchable: searchable,
8385
isMulti: multi,
8486
noOptionsMessage,
8587
inputId: this.inputId,
@@ -204,6 +206,7 @@ class Select extends Component {
204206

205207
Select.defaultProps = {
206208
multi: true,
209+
searchable: true,
207210
placeholder: 'Select...',
208211
size: 'regular',
209212
clearable: true,
@@ -255,6 +258,8 @@ Select.propTypes = {
255258
loading: PropTypes.bool,
256259
/** Text to display when loading options */
257260
loadingMessage: PropTypes.string,
261+
/** Support disabling search input and only allow select to change values. */
262+
searchable: PropTypes.bool,
258263
/** Support multiple selected options. */
259264
multi: PropTypes.bool,
260265
/** Text to display when there are no options. ({inputValue}) => string | null */

0 commit comments

Comments
 (0)