Skip to content

Commit

Permalink
fix: prevent un/mounting of date components (jquense#1276)
Browse files Browse the repository at this point in the history
I wanted to make a transition to date elements when they were selected, releasing that a couldn't get the `transition` property working. 

After some digging to my code and react-big-calendar code, I found that after selecting a date `DateContentRow` un&mount  their children components.

This happens due to the call of [this](https://github.com/intljusticemission/react-big-calendar/blob/master/src/DateContentRow.js#L121) `renderDummy` happens after setting `needLimitMeasure` to true in `Month.jsx` after the date is changed.

----------------------------

Prevent re-mount of DateContentRow children when date change in the same month
 * Prevent setting `needLimitMeasure` to true when the month of the date is not changed,
 in order to prevent unmounting and mounting of all the weeks' components.

 * Make it possible to add transition to the background of the event when
 implementing selection of date within the calendar.
  • Loading branch information
idanwe authored and jquense committed Apr 8, 2019
1 parent 9332ab7 commit 3c25009
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MonthView extends React.Component {

componentWillReceiveProps({ date }) {
this.setState({
needLimitMeasure: !dates.eq(date, this.props.date),
needLimitMeasure: !dates.eq(date, this.props.date, 'month'),
})
}

Expand Down Expand Up @@ -274,7 +274,7 @@ class MonthView extends React.Component {
end: slots[slots.length - 1],
action: slotInfo.action,
bounds: slotInfo.bounds,
box: slotInfo.box
box: slotInfo.box,
})
}

Expand Down

0 comments on commit 3c25009

Please sign in to comment.