Skip to content

Commit 801c029

Browse files
author
AthiraKadampatta
committed
Set preselection value to fix issue where the old date was staying selected on clicking Today button
1 parent 1d84d31 commit 801c029

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/calendar.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,20 @@ export default class Calendar extends React.Component {
691691
);
692692
};
693693

694+
handleTodayButtonClick = (e) => {
695+
this.props.onSelect(getStartOfToday(), e);
696+
this.props.setPreSelection(getStartOfToday());
697+
};
698+
699+
694700
renderTodayButton = () => {
695701
if (!this.props.todayButton || this.props.showTimeSelectOnly) {
696702
return;
697703
}
698704
return (
699705
<div
700706
className="react-datepicker__today-button"
701-
onClick={(e) => this.props.onSelect(getStartOfToday(), e)}
707+
onClick={(e) => this.handleTodayButtonClick(e)}
702708
>
703709
{this.props.todayButton}
704710
</div>

0 commit comments

Comments
 (0)