Skip to content

Commit 6ba73f5

Browse files
aleibMaja Wichrowska
authored andcommitted
Fix for initialVisibleMonth in DayPickerRangeController react-dates#613
1 parent a05a63f commit 6ba73f5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/DayPickerRangeController.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ export default class DayPickerRangeController extends React.Component {
806806
onOutsideClick,
807807
withPortal,
808808
enableOutsideDays,
809+
startDate,
809810
initialVisibleMonth,
810811
hideKeyboardShortcutsPanel,
811812
daySize,
@@ -819,6 +820,8 @@ export default class DayPickerRangeController extends React.Component {
819820
} = this.props;
820821

821822
const { phrases, visibleDays } = this.state;
823+
const initialVisibleMonthThunk =
824+
initialVisibleMonth || (startDate ? () => startDate : () => moment());
822825

823826
return (
824827
<DayPicker
@@ -837,7 +840,7 @@ export default class DayPickerRangeController extends React.Component {
837840
renderMonth={renderMonth}
838841
withPortal={withPortal}
839842
hidden={!focusedInput}
840-
initialVisibleMonth={initialVisibleMonth}
843+
initialVisibleMonth={initialVisibleMonthThunk}
841844
daySize={daySize}
842845
onOutsideClick={onOutsideClick}
843846
navPrev={navPrev}

0 commit comments

Comments
 (0)