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

readOnly <Calendar /> support #40

Closed
AshenCat opened this issue May 17, 2021 · 6 comments
Closed

readOnly <Calendar /> support #40

AshenCat opened this issue May 17, 2021 · 6 comments

Comments

@AshenCat
Copy link

AshenCat commented May 17, 2021

Thank you for this awesome calendar picker component!
I just have a question about the approach for making the calendar component read only and not change values when a date is clicked?

also, Typo on Calendar ref page (Opene instead of Open(?))

title: "Opene & Close Calendar By DatePicker Ref",

@shahabyazdi
Copy link
Owner

Hello
Thank you very much for reminding the typo.

Is this enough to make the calendar readOnly?

import { Calendar } from "react-multi-date-picker";
import { useState } from "react";

export default function App() {
  const [value, setValue] = useState();

  return <Calendar value={value} onChange={() => setValue({})} />;
}

Or do I need to add a readOnly prop for this purpose?

@AshenCat
Copy link
Author

AshenCat commented May 18, 2021

hmmm, I see that it works when the value is on a useState. For my use case, I have an array of objects with dates so I don't have a setValue for each iteration as all of the dates is on a single state. Putting an onChange with an empty function does not make the calendar read only.

@shahabyazdi
Copy link
Owner

I will add the readOnly prop in v2.9.0.
So that, when readOnly is activated, the user can no longer select a new date by the calendar

@shahabyazdi
Copy link
Owner

shahabyazdi commented May 19, 2021

Automatically closed with my merge command!

readOnly and disabled added to version 2.9.0.
Adding these properties disables the calendar and prevents the user from changing or editing the initial value.
Please take a look at these links and let me know if the problem persists.

1- Read Only Calendar
2- Disabled Calendar

@AshenCat
Copy link
Author

works perfectly now, thank you!

@shahabyazdi
Copy link
Owner

You're welcome.

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