react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Staying at the current month when selecting range.

Open ymoon715 opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. I currently have time range picker, where a user selects either yearly/monthly, and if they select today's date, it automatically chooses the range from today's to either year ago or month ago. However when that happens, the month automatically changes to a month/year ago and there is no way for me to control that.

Describe the solution you'd like A call back that I can use to control the year and the month im displaying, or a prop that prevents automatic change of year and date.

Describe alternatives you've considered I went through the doc and tried to change this in custom header, but so far no luck.

Additional context Is there any way to do this without using a hacky method like setTimeout?

ymoon715 avatar May 06 '22 22:05 ymoon715

Currently, I'm using set time out, and the UI flickers to the current month/date after selecting dates beyond/below the current date.

Is there plans of creating headless react hooks that we can use to create the calendar and allow more customizations?

ymoon715 avatar May 12 '22 20:05 ymoon715

@ymoon715 would you please share an example of your setTimeOut solution? Got this problem as well :/

un1tT avatar May 25 '22 11:05 un1tT

@ymoon715 would you please share an example of your setTimeOut solution? Got this problem as well :/

useEffect(() => { setTimeout(() => { if (to) { changeMonth(to.getMonth()); changeYear(to.getFullYear()); } }, 0); }, [frequency, from]);

The UI flickers, and this is probably the most brute force way you can achieve this. I dont recommend using setTimeout at all

ymoon715 avatar May 31 '22 22:05 ymoon715