Skip to content

Commit 5ba445c

Browse files
committed
disable flag for search feature and closeOnSelect fixed
1 parent bb5ce14 commit 5ba445c

File tree

8 files changed

+80
-73
lines changed

8 files changed

+80
-73
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.modern.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.modern.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/App.js

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
import React, { useState } from 'react'
2-
3-
import MultiSelect from 'react-multiple-select-dropdown-lite'
4-
import 'react-multiple-select-dropdown-lite/dist/index.css'
5-
6-
const App = () => {
7-
const [value, setvalue] = useState('rf,test,new')
8-
9-
const handleOnchange = val => {
10-
setvalue(val)
11-
}
12-
13-
const customStyle = {
14-
display: 'flex', justifyContent: 'space-between', alignItems: 'center'
15-
}
16-
17-
const options = [
18-
{ label: <div style={customStyle}><h1>Title</h1><span role="img" aria-label="agun">🔥</span></div>, value: 'option_1', title: 'option_1' },
19-
{ label: 'Option 2', value: '{id: 1}' },
20-
{ label: 'Select...', value: 'option_3' },
21-
{ label: 'Rf', value: 'option_4' },
22-
{
23-
title: 'group 1', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
24-
{ label: 'Option 5', value: 'option_5' },
25-
{ label: 'Option 6', value: 'option_6' },
26-
{
27-
title: 'group 2', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
28-
{ label: 'Option 7', value: 'option_7' },
29-
{ label: 'Option 8', value: 'option_8' },
30-
{
31-
title: 'group 3', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
32-
{ label: 'Option 9', value: 'option_9' },
33-
{ label: 'Option 10', value: 'option_10' }
34-
]
35-
},
36-
]
37-
},
38-
]
39-
},
40-
]
41-
42-
return (
43-
<div className="app">
44-
<div className="preview-values">
45-
<h4>Values</h4>
46-
{value.toString()}
47-
</div>
48-
<MultiSelect
49-
defaultValue={value}
50-
width={400}
51-
onChange={handleOnchange}
52-
options={options}
53-
customValue
54-
// singleSelect
55-
// clearable={false}
56-
// disableChip
57-
onMenuOpen={() => { console.log('menu open') }}
58-
onMenuClose={() => { console.log('menu Close') }}
59-
/>
60-
</div>
61-
)
62-
}
63-
64-
export default App
1+
import React, { useState } from 'react'
2+
3+
import MultiSelect from 'react-multiple-select-dropdown-lite'
4+
import 'react-multiple-select-dropdown-lite/dist/index.css'
5+
6+
const App = () => {
7+
const [value, setvalue] = useState('rf,test,new')
8+
9+
const handleOnchange = val => {
10+
setvalue(val)
11+
}
12+
13+
const customStyle = {
14+
display: 'flex', justifyContent: 'space-between', alignItems: 'center'
15+
}
16+
17+
const options = [
18+
{ label: <div style={customStyle}><h1>Title</h1><span role="img" aria-label="agun">🔥</span></div>, value: 'option_1', title: 'option_1' },
19+
{ label: 'Option 2', value: '{id: 1}' },
20+
{ label: 'Select...', value: 'option_3' },
21+
{ label: 'Rf', value: 'option_4' },
22+
{
23+
title: 'group 1', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
24+
{ label: 'Option 5', value: 'option_5' },
25+
{ label: 'Option 6', value: 'option_6' },
26+
{
27+
title: 'group 2', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
28+
{ label: 'Option 7', value: 'option_7' },
29+
{ label: 'Option 8', value: 'option_8' },
30+
{
31+
title: 'group 3', type: 'group', emptyDataLabel: 'No Group Option Found', childs: [
32+
{ label: 'Option 9', value: 'option_9' },
33+
{ label: 'Option 10', value: 'option_10' }
34+
]
35+
},
36+
]
37+
},
38+
]
39+
},
40+
]
41+
42+
return (
43+
<div className="app">
44+
<div className="preview-values">
45+
<h4>Values</h4>
46+
{value.toString()}
47+
</div>
48+
<MultiSelect
49+
defaultValue={value}
50+
width={400}
51+
onChange={handleOnchange}
52+
options={options}
53+
customValue
54+
// singleSelect
55+
// clearable={false}
56+
// disableChip
57+
onMenuOpen={() => { console.log('menu open') }}
58+
onMenuClose={() => { console.log('menu Close') }}
59+
/>
60+
</div>
61+
)
62+
}
63+
64+
export default App

src/MultiSelect.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ MultiSelect.defaultProps = {
3434
],
3535
customValue: false,
3636
chipAlternateText: 'Item Selected',
37-
closeOnSelect: true
37+
closeOnSelect: true,
38+
disableSearch: false,
3839
}
3940

4041
function MultiSelect({
@@ -62,7 +63,8 @@ function MultiSelect({
6263
onMenuOpen,
6364
onMenuClose,
6465
chipAlternateText,
65-
closeOnSelect
66+
closeOnSelect,
67+
disableSearch
6668
}) {
6769
const [value, setValue] = useState([])
6870
const [options, setOptions] = useState(userOptions || [])
@@ -160,7 +162,9 @@ function MultiSelect({
160162

161163
setValue(preDefinedValue)
162164
// close on option select
163-
closeOnSelect && singleSelect && setMenuOpen(false)
165+
if (closeOnSelect && singleSelect) {
166+
setMenuOpen(false)
167+
}
164168
}, [defaultValue])
165169

166170
const setNewValue = (val) => {
@@ -224,6 +228,9 @@ function MultiSelect({
224228
}
225229

226230
const showSearchOption = () => {
231+
if (disableSearch) {
232+
return false
233+
}
227234
if (!singleSelect && !disableChip) {
228235
return true
229236
} else if (singleSelect && !value.length) {

0 commit comments

Comments
 (0)