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 > When set two times value, calendar view is not updated #3258

Closed
JaiiRLopeZ opened this issue Sep 7, 2022 · 1 comment · Fixed by #3261
Closed

Calendar > When set two times value, calendar view is not updated #3258

JaiiRLopeZ opened this issue Sep 7, 2022 · 1 comment · Fixed by #3261
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@JaiiRLopeZ
Copy link

Describe the bug

When setValue two times, and next focus for opening calendar, is not updating calendar view

Example:

  • Click today button setValue(new Date())
  • Click December button setValue(new Date("2022-12-01T00:00:00"))
  • Focus calendar not show 1 December

image

Test on next sandbox (https://codesandbox.io/s/primereact-test-forked-ofltys?file=/src/index.js:1090-1131) , the next code:

import React, { useState } from "react";
import { createRoot } from "react-dom/client";
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 App = () => {
  const [value, setValue] = useState(null);

  return (
    <div className="App">
      <div>
        <h2>PrimeReact Issue Template</h2>
        <p>
          Please create a test case and attach the link to the to your github
          issue report.
        </p>
      </div>
      <div>
        <Calendar
          id="basic"
          value={value}
          onChange={(e) => setValue(e.value)}
          dateFormat="yy-mm-dd"
        />
      </div>
      <button
        type="button"
        onClick={() => {
          setValue(new Date());
        }}
      >
        Today
      </button>

      <button
        type="button"
        onClick={() => {
          setValue(new Date("2022-12-01T00:00:00"));
        }}
      >
        December
      </button>
    </div>
  );
};

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

Reproducer

No response

PrimeReact version

6.5.0

React version

17.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome

Steps to reproduce the behavior

  • Click today button setValue(new Date())
  • Click December button setValue(new Date("2022-12-01T00:00:00"))
  • Focus calendar not show 1 December

Expected behavior

  • Click today button setValue(new Date())
  • Click December button setValue(new Date("2022-12-01T00:00:00"))
  • Focus calendar show 1 December selected on Calendar View
@JaiiRLopeZ JaiiRLopeZ added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 7, 2022
melloware added a commit to melloware/primereact that referenced this issue Sep 8, 2022
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 8, 2022
@melloware melloware self-assigned this Sep 8, 2022
@melloware melloware added this to the 8.6.0 milestone Sep 8, 2022
@melloware
Copy link
Member

Thanks for the report!

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
Development

Successfully merging a pull request may close this issue.

2 participants