Skip to content

Commit 90f65ce

Browse files
authored
Merge pull request #660 from data-driven-forms/pf4-select-updates
Pf4 select updates
2 parents 1bb9190 + b807caa commit 90f65ce

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/pf4-component-mapper/demo/demo-schemas/select-schema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,5 @@ const selectSchema = {
164164
};
165165

166166
export default {
167-
...selectSchema,
168-
fields: [selectSchema.fields[0]]
167+
...selectSchema
169168
};

packages/pf4-component-mapper/demo/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class App extends React.Component {
5656
<FormRenderer
5757
onSubmit={console.log}
5858
initialValues={{
59-
'simple-select': 'Kay'
59+
'simple-select': 'Kay',
60+
'simple-async-select': 'Jenifer'
6061
}}
6162
componentMapper={{
6263
...componentMapper,

packages/pf4-component-mapper/src/common/select/input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const Input = ({ inputRef, isSearchable, isDisabled, getInputProps, value, ...pr
1414
{...{
1515
...inputProps,
1616
value: inputProps.value || '',
17+
onKeyDown: (event, ...args) => {
18+
event.stopPropagation();
19+
inputProps.onKeyDown(event, ...args);
20+
},
1721
onChange: inputProps.onChange || Function
1822
}}
1923
/>

packages/pf4-component-mapper/src/common/select/select.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ const itemToString = (value, isMulti, showMore, handleShowMore, handleChange) =>
6363
return value;
6464
};
6565

66-
const filterOptions = (options, filterValue = '') => options.filter(({ label }) => label.toLowerCase().includes(filterValue.toLowerCase()));
66+
// TODO fix the value of internal select not to be an array all the time. It forces the filter value to be an array and it crashes sometimes.
67+
const filterOptions = (options, filterValue = '') =>
68+
options.filter(({ label }) => {
69+
const filter = Array.isArray(filterValue) && filterValue.length > 0 ? filterValue[0] : filterValue;
70+
return label.toLowerCase().includes(filter.toLowerCase());
71+
});
6772

6873
const getValue = (isMulti, option, value) => {
6974
if (!isMulti || !option) {

0 commit comments

Comments
 (0)