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

Calendar : enabledDates is not evaluated with disabledDays #5863

Closed
sdwillbrand opened this issue Jan 31, 2024 · 5 comments · Fixed by #5864 or #5871
Closed

Calendar : enabledDates is not evaluated with disabledDays #5863

sdwillbrand opened this issue Jan 31, 2024 · 5 comments · Fixed by #5864 or #5871
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@sdwillbrand
Copy link
Contributor

Describe the bug

When using disabledDays passing enabledDates is not working.

Reproducer

https://codesandbox.io/p/sandbox/primereact-test-forked-cjy7lg?file=%2Fsrc%2Findex.js

PrimeReact version

latest

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@sdwillbrand sdwillbrand added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 31, 2024
@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Jan 31, 2024
@melloware melloware self-assigned this Jan 31, 2024
@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 31, 2024
@melloware melloware added this to the 10.4.0 milestone Jan 31, 2024
@melloware
Copy link
Member

I can't get to your Sandbox. Can you just paste your whole js file here in comment so I can see.

@sdwillbrand
Copy link
Contributor Author

import React, { useState } from "react";
import { createRoot } from "react-dom/client";
import { Button } from "primereact/button";
import { Calendar } from "primereact/calendar";
import "primereact/resources/themes/lara-light-indigo/theme.css"; //theme
import "primereact/resources/primereact.min.css"; //core css
import "primeicons/primeicons.css"; // icons
import "primeflex/primeflex.css"; // flex
import "./styles.css"; // application css

const disabledDates = [];

for (let i = 0; i < 400; i++) {
  disabledDates.push(new Date(new Date("2022-12-25").getTime() + 86400000 * i));
}

const App = () => {
  const [date, setDate] = useState(null);

  return (
    <div className="App">
      <Calendar
        value={date}
        onChange={(e) => setDate(e.value)}
        disabledDates={disabledDates}
        disabledDays={[0, 1, 2, 3]}
        enabledDates={[new Date("2024-02-19")]}
      />
    </div>
  );
};

const container = document.getElementById("root");
const root = createRoot(container);
root.render(<App />);

@melloware
Copy link
Member

Thanks!

@melloware
Copy link
Member

OK I think this is what you want:

image

@sdwillbrand
Copy link
Contributor Author

Exactly!!! Thank you!

melloware added a commit to melloware/primereact that referenced this issue Jan 31, 2024
melloware added a commit to melloware/primereact that referenced this issue Jan 31, 2024
sdwillbrand pushed a commit to sdwillbrand/primereact that referenced this issue Feb 1, 2024
@melloware melloware modified the milestones: 10.4.0, 10.4.1 Feb 1, 2024
@melloware melloware reopened this Feb 1, 2024
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 1, 2024
sdwillbrand pushed a commit to sdwillbrand/primereact that referenced this issue Feb 1, 2024
melloware added a commit that referenced this issue Feb 1, 2024
* Fix #5863: Calendar enabledDates fixed

* Fix #5863: format

* Update Calendar.js

---------

Co-authored-by: Melloware <[email protected]>
@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
2 participants