Skip to content

Commit a902e60

Browse files
fix(readOnly): disable click for inline calendar when set readOnly prop
1 parent 9d705ff commit a902e60

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ export default class DatePicker extends Component<
659659
event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,
660660
monthSelectedIn?: number,
661661
) => {
662+
if (this.props.readOnly) return;
662663
if (this.props.shouldCloseOnSelect && !this.props.showTimeSelect) {
663664
// Preventing onFocus event to fix issue
664665
// https://github.com/Hacker0x01/react-datepicker/issues/628
@@ -829,6 +830,7 @@ export default class DatePicker extends Component<
829830

830831
// When checking preSelection via min/maxDate, times need to be manipulated via getStartOfDay/getEndOfDay
831832
setPreSelection = (date?: Date | null): void => {
833+
if (this.props.readOnly) return;
832834
const hasMinDate = isDate(this.props.minDate);
833835
const hasMaxDate = isDate(this.props.maxDate);
834836
let isValidDateSelection = true;

0 commit comments

Comments
 (0)