Skip to content

Commit 5e11d88

Browse files
committed
fix(pf4): downshift select disabled prop
1 parent 34930bb commit 5e11d88

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const selectSchema = {
3030
name: 'simple-select',
3131
label: 'Simple-select',
3232
options
33+
},
34+
{
35+
component: componentTypes.SELECT,
36+
name: 'disabled-select',
37+
label: 'Disabled-select',
38+
options,
39+
isDisabled: true
3340
}
3441
]
3542
};

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import './select-styles.scss';
1111
import Input from './input';
1212
import Menu from './menu';
1313

14-
const InternalSelect = ({ onChange, options, value, simpleValue, placeholder, isSearchable, ...props }) => {
14+
const InternalSelect = ({ onChange, options, value, simpleValue, placeholder, isSearchable, isDisabled, ...props }) => {
1515
// console.log(props);
1616
const inputRef = useRef();
1717
const parsedValue = parseInternalValue(value);
@@ -37,9 +37,18 @@ const InternalSelect = ({ onChange, options, value, simpleValue, placeholder, is
3737
};
3838
return (
3939
<div className="pf-c-select">
40-
<button className="pf-c-select__toggle" {...enhancedToggleButtonProps}>
40+
<button disabled={isDisabled} className={`pf-c-select__toggle${isDisabled ? ' pf-m-disabled' : ''}`} {...enhancedToggleButtonProps}>
4141
<div className="pf-c-select_toggle-wrapper ddorg__pf4-component-mapper__select-toggle-wrapper">
42-
<Input inputRef={inputRef} placeholder={placeholder} className="pf-c-select_toggle-text" {...getInputProps()} value={value} />
42+
<Input
43+
inputRef={inputRef}
44+
isSearchable={isSearchable}
45+
placeholder={placeholder}
46+
className="pf-c-select_toggle-text"
47+
{...getInputProps({
48+
disabled: isDisabled
49+
})}
50+
value={value}
51+
/>
4352
</div>
4453
<span className="pf-c-select__toggle-arrow">
4554
<CaretDownIcon />
@@ -66,8 +75,9 @@ InternalSelect.propTypes = {
6675
placeholder: PropTypes.string,
6776
isSearchable: PropTypes.bool,
6877
id: PropTypes.string,
69-
name: PropTypes.string.isRequired
70-
}
78+
name: PropTypes.string.isRequired,
79+
isDisabled: PropTypes.bool
80+
};
7181

7282
const Select = ({ selectVariant, menuIsPortal, ...props }) => {
7383
const isSearchable = selectVariant === 'createable' || props.isSearchable;

0 commit comments

Comments
 (0)