Skip to content

Commit

Permalink
minor update to cell selection. Still has issue that the cells do not…
Browse files Browse the repository at this point in the history
… redraw with a selected state unless hoverd on or changing the month under the mouse pointer
  • Loading branch information
harel committed Mar 28, 2017
1 parent bac9d39 commit f4d8fcb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/modules/Datetime/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,15 @@ export default class Month extends Component {
}
dayCellDate.setDate(dayParams.day)
dayParams.date = dayCellDate
if (dayParams.date >= selectionStart && dayParams.date <= selectionEnd) {
dayParams.selected = true
}
if (selectionStart) {
dayParams.onMouseOver = () => {
this.setState({
selectionEnd: dayParams.date,
})
}
}
dayParams.selected = this.isCellSelected(dayCellDate, selectionStart, selectionEnd)

if (hasDisabledDates && !dayParams.disabled &&
disabledDateSig.indexOf(this.getDateString(dayParams.date)) > -1) {
dayParams.disabled = true
Expand All @@ -154,6 +153,15 @@ export default class Month extends Component {
})
}

/**
* Returns true if the cell is within the start/end of the selection
*/
isCellSelected(date, selectionStart, selectionEnd) {
return selectionStart && selectionStart <= date
&& selectionEnd && selectionEnd >= date
&& selectionEnd > selectionStart;
}

getMonthDays() {
const days = this.getDays()
const cells = []
Expand Down

0 comments on commit f4d8fcb

Please sign in to comment.