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

Double view calendar switches activeStartDate to the next month when the date is selected on the right #339

Open
majsterkoo opened this issue Mar 17, 2020 · 14 comments
Labels
bug Something isn't working fresh

Comments

@majsterkoo
Copy link

Hi,
I'm using ReactCalendar in uncontrolled mode. How I can prevent calendar to switch to next month if click on date on right side in showDoubleView? When on left is June, on right July, then after select some date in July calendar render July in left side and next month is showed in right side.

//fetchWeeks - function to call api request for other component
<ReactCalendar showWeekNumbers showDoubleView onChange={fetchWeeks} defaultValue={today} />

Thanks for help/advice.

@carlosbensant
Copy link

The UX experience is being affected by this issue (there should be a way to disable it).

@lauterry
Copy link

Hi

Has someone found a workaround to disable this behavior please ? Or Can the author provide a props to disable it please ?

Thx a lot

Best regards

@leolozes
Copy link

I think this behaviour should be configurable. However, I think what it really needs is an animation to show the transition to the user. Right now it's really difficult for the user to see what is going on.

@lauterry
Copy link

lauterry commented Feb 7, 2021

I have just opened an issue to request an animation to show the transition to the user

#483

@ernie-h
Copy link

ernie-h commented Feb 12, 2021

If you look at this issue, OP seems to have run into a similar problem. He hacked together a solution by changing the activeStartDate prop through the onActiveStartDateChange and onChange handler.

Digging through the react-calendar code, the problem while in double view is that the onChange handler in Calendar.jsx sets an activeStartDate each time, which is why clicking on the next month teleports you there.

onChange = (value, event) => { 
... 
this.setStateAndCallCallbacks({	    
      activeStartDate: nextActiveStartDate,
      value: nextValue,
    });
}

A possible solution would be to add a showDoubleView condition that only sets activeStartDate: nextActiveStartDate when you are in a single month view.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2021

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Nov 1, 2021
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 14 days with no activity.

@wojtekmaj wojtekmaj added the question Further information is requested label Nov 22, 2021
@leolozes
Copy link

leolozes commented Dec 3, 2021

Edit: nevermind, we implemented our own calendar.

Any updates on this? The issue has been closed, but the UX is still quite bad, and a lot of users don't understand what is going on and end up selecting a much bigger range than intended.

A quick demo to see the effect and understand the problem. The user doesn't move his cursor, but is automatically positioned in the next month:

chrome-capture

@wojtekmaj wojtekmaj added bug Something isn't working and removed question Further information is requested stale labels Dec 5, 2021
@wojtekmaj wojtekmaj reopened this Dec 5, 2021
@github-actions github-actions bot added the stale label Mar 7, 2022
Repository owner deleted a comment from github-actions bot Mar 21, 2022
Repository owner deleted a comment from github-actions bot Mar 21, 2022
@wojtekmaj wojtekmaj added fresh and removed stale labels Mar 21, 2022
@wojtekmaj wojtekmaj reopened this Mar 21, 2022
@wojtekmaj wojtekmaj changed the title doubleview calendar switch to next month on right date select Double view calendar switches activeStartDate to the next month when the date is selected on the right Mar 21, 2022
@swee76
Copy link

swee76 commented Oct 23, 2022

any update to this?

@swee76
Copy link

swee76 commented Oct 31, 2022

@wojtekmaj How to make the calendar keep on the same side when click on the value which is in right side? I wanted to create a calendar which is important to filter past 3 months of data. So basically current month should be on right side, instead of left side.. Whatever that, when click on the any date which is in right side calendar month moves to the left side, please could you fix this?

@lauterry
Copy link

Hello

Please re consider fixing this issue please ?

Thank you.

@Nmkop1
Copy link

Nmkop1 commented Jan 26, 2023

Great calendar, just how to disable this moving the month to the left, after clicking on the value located on the right.

@MarcosMoraes23
Copy link

Same problem here.

Any updates ?

@svekko
Copy link

svekko commented Jun 6, 2023

Solution I used, seems to work fine for me. Maybe It's useful to someone else too:

Make activeStartDate controlled:

const [activeStartDate, setActiveStartDate] = useState(new Date());

Set following props on Calendar component:

goToRangeStartOnSelect={false}
activeStartDate={activeStartDate}

On activeStartDate do following so that onChange event doesn't trigger activeStartDate change:

onActiveStartDateChange={(data) => {
    if (data.action !== "onChange") {
        setActiveStartDate(data.activeStartDate);
    }
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fresh
Projects
None yet
Development

No branches or pull requests

10 participants