Skip to content

Commit b807caa

Browse files
committed
fix(pf4): hotfix select wring filter value type.
1 parent 82c04c0 commit b807caa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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/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)