Skip to content

Commit cfc0010

Browse files
Ben Hancockarthurdenner
Ben Hancock
authored andcommitted
fix(datepicker): showCalendar no longer triggers if readOnly is true (#42)
* chore: Update kcd-scripts (#43) * fix(datepicker): showCalendar no longer triggers if readOnly is true
1 parent 480fbee commit cfc0010

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@storybook/react": "^3.4.0",
4848
"babel-core": "^6.26.0",
4949
"babel-runtime": "^6.26.0",
50-
"kcd-scripts": "^1.4.0",
50+
"kcd-scripts": "^1.8.0",
5151
"prop-types": "^15.6.1",
5252
"react": ">=16.2.1",
5353
"react-dom": ">=16.2.1",

src/components/datepicker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class SemanticDatepicker extends React.Component {
9191
pointing: 'left',
9292
selected: null,
9393
type: 'basic',
94+
readOnly: false,
9495
};
9596

9697
componentDidUpdate(prevProps) {
@@ -340,7 +341,7 @@ class SemanticDatepicker extends React.Component {
340341
selectedDateFormatted,
341342
typedValue,
342343
} = this.state;
343-
const { clearable, locale, pointing, filterDate } = this.props;
344+
const { clearable, locale, pointing, filterDate, readOnly } = this.props;
344345
return (
345346
<div
346347
className="field"
@@ -355,7 +356,7 @@ class SemanticDatepicker extends React.Component {
355356
onBlur={this.handleBlur}
356357
onChange={this.handleChange}
357358
onClear={this.resetState}
358-
onClick={this.showCalendar}
359+
onClick={readOnly ? null : this.showCalendar}
359360
onKeyDown={this.handleKeyDown}
360361
value={typedValue || selectedDateFormatted}
361362
/>

0 commit comments

Comments
 (0)