Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conditions when adjustDayPickerHeight is called #1241

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

nnishimura
Copy link

@nnishimura nnishimura commented Jul 1, 2018

Fixes #443

Replaces #446, #640

  • Added checks for daySize and orientation in DayPicker.componentDidUpdate() so that DayPicker height is recalculated if either of these change between renders
  • Added new tests for DayPicker.componentDidUpdate

@coveralls
Copy link

coveralls commented Jul 1, 2018

Coverage Status

Coverage decreased (-0.2%) to 84.436% when pulling ab8c80b on nnishimura:fix/adjustDayPickerHeight2 into f79915e on airbnb:master.

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick fix and we should be good to go! Thank you for writing tests!

this.isHorizontal()
&& (orientation !== prevProps.orientation || daySize !== prevProps.daySize)
) {
this.adjustDayPickerHeight();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in #1192, we changed this function so that it now takes a value. If we change this line to:

      const visibleCalendarWeeks = this.calendarMonthWeeks.slice(0, numberOfMonths);
      const calendarMonthWeeksHeight = Math.max(0, ...visibleCalendarWeeks) * (daySize - 1);
      const newMonthHeight = monthTitleHeight + calendarMonthWeeksHeight + 1;
      this.adjustDayPickerHeight(newMonthHeight);

that should work (monthTitleHeight is in state).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@majapw thanks for the catch, have updated.

@nnishimura nnishimura force-pushed the fix/adjustDayPickerHeight2 branch 4 times, most recently from 3d3e06c to a60cabc Compare July 6, 2018 06:54
this.isHorizontal()
&& (orientation !== prevProps.orientation || daySize !== prevProps.daySize)
) {
const visibleCalendarWeeks = this.calendarMonthWeeks.slice(0, numberOfMonths);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah shit, this should be this.calendarMonthWeeks.slice(1, numberOfMonths + 1); (we have to slice off the first and last months because they are hidden). I will update this.

* Added checks for daySize and orientation in DayPicker.componentDidUpdate() so that DayPicker height is recalculated if either of these change between renders
* Added new tests for DayPicker.componentDidUpdate
@majapw majapw force-pushed the fix/adjustDayPickerHeight2 branch from a60cabc to ab8c80b Compare July 12, 2018 23:39
@majapw
Copy link
Collaborator

majapw commented Jul 12, 2018

All right! This looks great! I'll merge in when tests pass. :)

@majapw majapw merged commit 5f55b62 into react-dates:master Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants