question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

With 2 months shown and inline calendar, the months shift when range selected spans the 2 months

See original GitHub issue

I have an inline calendar with 2 months shown. Whenever a user selects a date range that spans the 2 months, if the range is not in the same month, the left month slides out of view. As seen in the gif below, In order to view the full range, a user must select the back arrow to see the range again.

datepicker1

Here is my code

<DatePicker
  inline
  selected={this.state.startDate}
  startDate={this.state.startDate}
  endDate={this.state.endDate}
  onChange={this.handleDateSelect}
  monthsShown={2}
  shouldCloseOnSelect={false}
/>

I feel as if there should be a prop to enable / disable this.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
aijcommented, Apr 2, 2018

I don’t think the months were intended to shift when selecting a day. It seems like a buggy interaction between monthsShown and inline. (Normally, the date picker would close after selecting a date, so re-opening to the last selected date is fine/expected, but staying open and shifting is weird.)

2reactions
NoelBaroncommented, Jul 20, 2021

This is definitely not fixed… 2021 😆

Have you tried this? focusSelectedMonth={true}

@BeKnowDo this is actually fixed with focusSelectedMonth={false}. See gif. MultiMonthFocus

<DatePicker 
  focusSelectedMonth={false}
  startDate={startDate}
  endDate={endDate}
  monthsShown={2}
  selectsRange
  inline
  disabledKeyboardNavigation // <-- active-day bug is still open
  onChange={(e) => {  setDateRange(e) }}
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Date Range Picker — JavaScript Date & Time Picker Library
A JavaScript component for choosing date ranges, dates and times. ... the two calendars displayed will always be for two sequential months (i.e....
Read more >
<input type="month"> - HTML: HyperText Markup Language
A string representing the value of the month and year entered into the input, in the form YYYY-MM (four or more digit year,...
Read more >
Calendar Multi month view Example | Mobiscroll
JQuery multi-month calendar. Always or dynamically show one, two or three months side by side depending on screen size.
Read more >
React Datepicker crafted by HackerOne
A simple and reusable datepicker component for React.
Read more >
Date picker - Shopify Polaris
The selected date or range of dates. monthnumber. The month to show, from 0 to 11. 0 is January, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found