palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.65k stars 2.17k forks source link

DateInput3 showing the wrong date #6839

Open synapse opened 4 months ago

synapse commented 4 months ago

The DateInput3 is showing previous date provided to the value prop

Screenshot 2024-05-31 at 08 25 03

Environment

Code Sandbox

Link to a minimal repro (fork this code sandbox):

Steps to reproduce

export default function App() {
  const date = moment("2024-05-07").format("L")

  const formatDate = (date) => {
    return moment(date).format("L");
  };

  const parseDate = (str) => {
      return moment(str, "L").toDate();
  };

  return (
    <div className="App">
      <h2>{date}</h2>  👈  this is different from the value inside the input (shows 05/07/2024)

      <DateInput3
        value={date}
        locale="en-US"
        highlightCurrentDay
        formatDate={formatDate}
        parseDate={parseDate}
        popoverProps={{ minimal: true, placement: "bottom-start" }}
    />
    </div>
  );
}

Actual behavior

Instead of showing 05/07/2024 it is showing 05/06/2024

Expected behavior

To show the correct date

Possible solution

invliD commented 3 months ago

The example from the code sandbox is showing 05/07/2024 for me as expected. What time zone is your system set to, and at what (local) time did you encounter this bug?

synapse commented 3 months ago

@invliD I'm on Europe/Rome tz and the locale is set to the default one en