Skip to content

Commit 5b34609

Browse files
committed
Fix #82: Also set disabled attr when readonly is true
1 parent b5b5d84 commit 5b34609

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/components/autocomplete.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export default class AutoCompleteInput extends React.Component {
130130
help_text={this.props.help_text}
131131
error={this.props.error}
132132
readOnly={true}
133+
disabled={this.props.readOnly || false}
133134
onClick={this.toggleOptions}
134135
inputRef={this.input}
135136
placeholder={this.props.placeholder}

src/components/form.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export function FormInput({label, help_text, error, inputRef, ...props}) {
3434
if (props.type == 'hidden')
3535
wrapperProps['style'] = {display: 'none'};
3636

37+
// readonly inputs are automatically marked disabled
38+
// if this is undesired, explicitly pass disabled=false
39+
if (props.readOnly && (props.disabled === undefined || props.disabled === null))
40+
props.disabled = true;
41+
3742
return (
3843
<div {...wrapperProps}>
3944
<Label label={label} required={props.required} />
@@ -768,6 +773,7 @@ export class FormDateTimeInput extends React.Component {
768773
value={this.state.hh + ':' + this.state.mm + ':' + this.state.ss + ' ' + this.state.ampm}
769774
onFocus={this.showTimePicker}
770775
readOnly={true}
776+
disabled={this.props.readOnly || false}
771777
inputRef={this.timeInput}
772778
/>
773779
<div ref={this.timePickerContainer}>

0 commit comments

Comments
 (0)