Skip to content

Commit 386bf42

Browse files
committed
fix: adjust logic for handling initialCalendarDate
1 parent c3d3d14 commit 386bf42

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/components/Input/DateInput.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,15 @@ export default class DateInput extends React.Component {
198198
return this.state.value;
199199
};
200200

201-
getCurrentDate = () =>
202-
parseValue(
203-
this.props.value !== undefined
201+
getCurrentDate = () => {
202+
// If value prop is provided and not empty, use it
203+
// Otherwise, use state.value if available, or fall back to initialCalendarDate
204+
const valueToUse =
205+
this.props.value !== undefined && this.props.value !== ''
204206
? this.props.value
205-
: this.state.value || this.props.initialCalendarDate,
206-
this.props.dateFormat,
207-
this.props.parse
208-
);
207+
: this.state.value || this.props.initialCalendarDate;
208+
return parseValue(valueToUse, this.props.dateFormat, this.props.parse);
209+
};
209210

210211
parseInput = (value) => {
211212
const date = this.props.parse(value, this.props.dateFormat);

0 commit comments

Comments
 (0)