MCPcopy Index your code
hub / github.com/react-dates/react-dates / componentDidUpdate

Method componentDidUpdate

src/components/DayPicker.jsx:382–418  ·  view source on GitHub ↗
(prevProps, prevState)

Source from the content-addressed store, hash-verified

380 }
381
382 componentDidUpdate(prevProps, prevState) {
383 const {
384 orientation, daySize, isFocused, numberOfMonths,
385 } = this.props;
386 const {
387 currentMonth,
388 currentMonthScrollTop,
389 focusedDate,
390 monthTitleHeight,
391 } = this.state;
392
393 if (
394 this.isHorizontal()
395 && (orientation !== prevProps.orientation || daySize !== prevProps.daySize)
396 ) {
397 const visibleCalendarWeeks = this.calendarMonthWeeks.slice(1, numberOfMonths + 1);
398 const calendarMonthWeeksHeight = Math.max(0, ...visibleCalendarWeeks) * (daySize - 1);
399 const newMonthHeight = monthTitleHeight + calendarMonthWeeksHeight + 1;
400 this.adjustDayPickerHeight(newMonthHeight);
401 }
402
403 if (!prevProps.isFocused && isFocused && !focusedDate) {
404 this.container.focus();
405 }
406
407 // If orientation is VERTICAL_SCROLLABLE and currentMonth has changed adjust scrollTop so the
408 // new months rendered above the current month don't push the current month out of view.
409 if (
410 orientation === VERTICAL_SCROLLABLE
411 && !isSameMonth(prevState.currentMonth, currentMonth)
412 && currentMonthScrollTop
413 && this.transitionContainer
414 ) {
415 this.transitionContainer.scrollTop = this.transitionContainer.scrollHeight
416 - currentMonthScrollTop;
417 }
418 }
419
420 componentWillUnmount() {
421 clearTimeout(this.setCalendarInfoWidthTimeout);

Callers

nothing calls this directly

Calls 3

isHorizontalMethod · 0.95
adjustDayPickerHeightMethod · 0.95
isSameMonthFunction · 0.85

Tested by

no test coverage detected