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

How to show last month and this month on popover (Ranged) #52

Open
mjemerson opened this issue May 16, 2023 · 4 comments
Open

How to show last month and this month on popover (Ranged) #52

mjemerson opened this issue May 16, 2023 · 4 comments

Comments

@mjemerson
Copy link

Hi,

A quick question hopefully that can be answered easily - when the Range picker is employed, by default if it's set to show 2 months it's the current month and then next month. However for my needs, all future dates are disabled so it makes no sense to show next month on the right hand side since they're all disabled. So my question is, is there a way to offset it so that the two months showing are last month THEN this month side by side? I found something called offset but it doesn't seem to be settable from either the DatePicker props or the configs?

@aboveyunhai
Copy link
Owner

aboveyunhai commented May 16, 2023

I don't think it's possible to do it with the current version, but if you would like to copy&paste the source code (I always encourage that since the lib is relatively tiny) into your own folder,
then

const [dateInView, setDateInView] = useState(selectedDates[0] || new Date());

and
setDateInView(selectedDates[0] || new Date());

is what you are looking for,
basically new Date() - 1 month is what you want
Or you can export the Range calendar and build your own popover, just directly copy&paste the range file only and still use this package as dependency.

@mjemerson
Copy link
Author

Thank you, I'll give it a try!

@mjemerson
Copy link
Author

Hi again,

I'm having many issues trying to reference the datepicker from my local components folder, so in the end decided to give it up. Is there no way to call setDateInView from my source files by passing it to the date picker component somewhere? Or set a specific prop to a value?

@aboveyunhai
Copy link
Owner

aboveyunhai commented May 17, 2023

@mjemerson currently no, I think you can just copy paste the range.tsx source file and change the const import to this package, it's bit of redundant, but it should be fine and you can change however you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants