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.

Cannot indicate which month is visible on open

See original GitHub issue

Ideally this should be a controlled prop that would default to the current month. That way you can close the <DayPicker /> and reopen to where you were previously

My vision is that this would be a currentMonth prop on the SingleDatePicker and on the DateRangePicker that would take in a moment object. If a parent component wanted to keep track of this in the state then, they could do so using the onPrevMonthClick and onNextMonthClick callbacks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:26 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
majapwcommented, Aug 19, 2016

I think that the fine tuned control of this prop allows for behavior like:

  • User opens date picker, navigates to 6 months in the future
  • User closes date picker without selecting a date
  • User reopens the date picker, it is still 6 months in the future

I think that while in a lot of cases, it makes sense to open to the start date month, we want to be able to cover all options easily, especially those cases where no date has been selected.

On Fri, Aug 19, 2016, 10:29 AM jcreamer898 notifications@github.com wrote:

So, is there any reason why when using DRP it wouldn’t just open to the month containing the startDate that was passed in?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/airbnb/react-dates/issues/17#issuecomment-241050316, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUdtf7V2pArC6DcLvLNiSjzvO_fFnDAks5qhcvFgaJpZM4JoAzb .

1reaction
jenniferleveauxcommented, Aug 3, 2017

@sag1v You can access to the currentMoment state (moment object) in your parent component by adding a ref to the date component this.dayPicker.state.currentMonth

Day picker implementation with ref and prev/next callbacks.

 <DayPicker
    ref={(dayPicker) => { this.dayPicker = dayPicker; }}
    onPrevMonthClick={this.prevMonthClick}
    onNextMonthClick={this.nextMonthClick}
 />

But at this moment, currentMonth hasn’t yet been updated (+/- 1 month) because the callback method is called before updating the state value.

@majapw Is there a better way to get this value without adding or removing 1 month manually like I did ?

   nextMonthClick() {
        const newMonth = this.dayPicker.state.currentMonth.clone().add(1, 'month');
        this.setState({ currentMonth: newMonth });
    }

callback method call (called before state update) DayPicker.jsx#L543 and finally, the state update of currentMonth DayPicker.jsx#L567

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Excel Dates That Won't Change Format - Contextures
In the drop down list, click on the date format that your dates are currently displayed in. In this example, the dates are...
Read more >
View your day, week, or month - Google Calendar Help
On your computer, open Google Calendar. In the top right, choose a view: Day, Week, Month, Year, Schedule, or 4 days. ... Show...
Read more >
Check and update your calendar on Apple Watch
Open the Calendar app on your Apple Watch, or tap the date or a calendar event on ... Show the current month: While...
Read more >
Change how you view your Outlook calendar - Microsoft Support
Keep upcoming calendar items visible. Keep your upcoming appointments and meetings ... Change to Month view with a Monday start date and show...
Read more >
Fetal Pole: Ultrasound, Anatomy & Function - Cleveland Clinic
Whether there's a pregnancy complication: If the fetal pole is unexpectedly small or not seen, it may indicate incorrect dates or a ...
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