Skip to content

Commit 33c9ccf

Browse files
committed
fix(pf4): added disabled option to downshift select
1 parent bdd47bf commit 33c9ccf

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ const selectSchema = {
121121
label: 'Clearable-select',
122122
options,
123123
isSearchable: true
124+
},
125+
{
126+
component: componentTypes.SELECT,
127+
name: 'dosbaled-option-select',
128+
label: 'Disabled-option-select',
129+
options: [...options, { label: 'Disabled option', value: 'disabled', isDisabled: true }]
124130
}
125131
]
126132
};

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { CheckIcon } from '@patternfly/react-icons';
55

66
const Option = ({ item, isActive, isSelected, ...props }) => (
77
<li>
8-
<button {...props} type="button" className={`pf-c-select__menu-item${isSelected ? ' pf-m-selected' : ''}${isActive ? ' pf-m-focus' : ''}`}>
8+
<button
9+
{...props}
10+
disabled={item.isDisabled || item.disabled}
11+
type="button"
12+
className={`pf-c-select__menu-item${isSelected ? ' pf-m-selected' : ''}${isActive ? ' pf-m-focus' : ''}${
13+
item.isDisabled || item.disabled ? ' pf-m-disabled' : ''
14+
}`}
15+
>
916
{item.label}
1017
{isSelected && (
1118
<span className="pf-c-select__menu-item-icon">
@@ -18,7 +25,9 @@ const Option = ({ item, isActive, isSelected, ...props }) => (
1825

1926
Option.propTypes = {
2027
item: PropTypes.shape({
21-
label: PropTypes.node
28+
label: PropTypes.node,
29+
isDisabled: PropTypes.bool,
30+
disabled: PropTypes.bool
2231
}).isRequired,
2332
isActive: PropTypes.bool,
2433
isSelected: PropTypes.bool,

0 commit comments

Comments
 (0)