Skip to content

Commit 82839da

Browse files
committed
revert me
1 parent 136bea7 commit 82839da

1 file changed

Lines changed: 16 additions & 71 deletions

File tree

Lines changed: 16 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,32 @@
11
import React, { useState } from 'react';
22

3-
import { EuiComboBox } from '../../../../src/components';
4-
import { DisplayToggles } from '../form_controls/display_toggles';
3+
import { EuiComboBox, EuiFieldText } from '../../../../src/components';
54

6-
const optionsStatic = [
7-
{
8-
label: 'Titan',
9-
'data-test-subj': 'titanOption',
10-
},
11-
{
12-
label: 'Enceladus is disabled',
13-
disabled: true,
14-
},
15-
{
16-
label: 'Mimas',
17-
},
18-
{
19-
label: 'Dione',
20-
},
21-
{
22-
label: 'Iapetus',
23-
},
24-
{
25-
label: 'Phoebe',
26-
},
27-
{
28-
label: 'Rhea',
29-
},
30-
{
31-
label:
32-
"Pandora is one of Saturn's moons, named for a Titaness of Greek mythology",
33-
},
34-
{
35-
label: 'Tethys',
36-
},
37-
{
38-
label: 'Hyperion',
39-
},
40-
];
415
export default () => {
42-
const [options, setOptions] = useState(optionsStatic);
43-
const [selectedOptions, setSelected] = useState([options[2], options[4]]);
6+
const [name, setName] = useState('');
447

45-
const onChange = (selectedOptions) => {
46-
setSelected(selectedOptions);
8+
const onSubmit = (ev) => {
9+
ev.preventDefault();
10+
ev.stopPropagation();
11+
window.alert('form submitted');
4712
};
4813

49-
const onCreateOption = (searchValue, flattenedOptions = []) => {
50-
const normalizedSearchValue = searchValue.trim().toLowerCase();
14+
const options = [
15+
{ label: 'Chandler', color: 'hotpink' },
16+
{ label: 'Rachel', color: 'green' },
17+
];
5118

52-
if (!normalizedSearchValue) {
53-
return;
54-
}
55-
56-
const newOption = {
57-
label: searchValue,
58-
};
59-
60-
// Create the option if it doesn't exist.
61-
if (
62-
flattenedOptions.findIndex(
63-
(option) => option.label.trim().toLowerCase() === normalizedSearchValue
64-
) === -1
65-
) {
66-
setOptions([...options, newOption]);
67-
}
68-
69-
// Select the option.
70-
setSelected([...selectedOptions, newOption]);
71-
};
19+
const [selectedOptions, setSelectedOptions] = useState([]);
7220

7321
return (
74-
/* DisplayToggles wrapper for Docs only */
75-
<DisplayToggles canDisabled={false} canReadOnly={false}>
22+
<form onSubmit={onSubmit}>
23+
<EuiFieldText value={name} onChange={(ev) => setName(ev.target.value)} />
7624
<EuiComboBox
77-
placeholder="Select or create options"
7825
options={options}
26+
onChange={(options) => setSelectedOptions(options)}
7927
selectedOptions={selectedOptions}
80-
onChange={onChange}
81-
onCreateOption={onCreateOption}
82-
isClearable={true}
83-
data-test-subj="demoComboBox"
8428
/>
85-
</DisplayToggles>
29+
{/* <input type="submit" /> */}
30+
</form>
8631
);
8732
};

0 commit comments

Comments
 (0)