Skip to content

Commit 782d830

Browse files
committed
DateTime: Fix bug where clicking the 31st of the prior month incorrectly selects the 1st of that month when in the current month display
1 parent ddd8da3 commit 782d830

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/DateTime.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ export default class Datetime extends React.Component {
327327
let updateOnView = this.getUpdateOn(this.getFormat("date"))
328328
let viewDate = this.state.viewDate.clone()
329329

330-
// Set the value into day/month/year
331-
viewDate[this.viewToMethod[currentView]](parseInt(e.target.getAttribute("data-value"), 10))
332-
333330
// Need to set month and year will for days view (prev/next month)
334331
if (currentView === "days") {
335332
viewDate.month(parseInt(e.target.getAttribute("data-month"), 10))
336333
viewDate.year(parseInt(e.target.getAttribute("data-year"), 10))
337334
}
338335

336+
// Set the value into day/month/year
337+
viewDate[this.viewToMethod[currentView]](parseInt(e.target.getAttribute("data-value"), 10))
338+
339339
let update = { viewDate: viewDate }
340340
if (currentView === updateOnView) {
341341
update.selectedDate = viewDate.clone()

0 commit comments

Comments
 (0)