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

[bug]: Date Picker decrements day by one when focus state changes #95

Closed
2 tasks done
zoutiyx opened this issue Jun 12, 2024 · 12 comments
Closed
2 tasks done

[bug]: Date Picker decrements day by one when focus state changes #95

zoutiyx opened this issue Jun 12, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@zoutiyx
Copy link

zoutiyx commented Jun 12, 2024

Describe the bug

The day selected using the Date Picker decrements by one when the focus state changes with a click/press/tab, out of the input field. If the day of the current month is 1 before the click, it goes down to the last day of the previous month when the focus changes.

date-picker-focus-bug.mov

Affected component/components

Date Picker

How to reproduce

  1. Select any date in Component
  2. Click/press/tab out of the input field

Codesandbox/StackBlitz link

https://imgur.com/a/hHCA2DV

Logs

No response

System Info

Safari 17.4.1 => https://shadcn-solid.com/docs/components/date-picker

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@zoutiyx zoutiyx added the bug Something isn't working label Jun 12, 2024
@hngngn
Copy link
Owner

hngngn commented Jun 13, 2024

Can you check the preview in #86 to see if this is still happening?

@hngngn
Copy link
Owner

hngngn commented Jun 13, 2024

I've tried several browsers, but I can't reproduce the problem you're having, even on the main site.

@zoutiyx
Copy link
Author

zoutiyx commented Jun 14, 2024

Can you check the preview in #86 to see if this is still happening?

It is still happening in the preview. I tried using Safari, Brave and Google Chrome on Mac and Windows.

@hngngn
Copy link
Owner

hngngn commented Jun 18, 2024

I've tried it on Windows and Mac too, but everything seems to be working fine.

@zoutiyx
Copy link
Author

zoutiyx commented Jun 18, 2024

I am unsure of the origins of this bug, but it is still present on Windows and Mac for the latest preview. Any idea how this issue can be narrowed down?

@hngngn
Copy link
Owner

hngngn commented Jun 18, 2024

I'm sorry, but I cannot fix a bug that I have not encountered. I have tried many things but cannot replicate the issue.

@hngngn
Copy link
Owner

hngngn commented Jun 18, 2024

Have you tried it on a new project yet?

@zoutiyx
Copy link
Author

zoutiyx commented Jun 19, 2024

Yes, I have. I even used [email protected] to no avail.

Steps to reproduce the bug using the deployment link below:

  1. Select a random date in the picker
  2. Click out of the picker input box

You can check it out here: https://shadcn-solid-date-picker-28f413o1r-zoutiyxs-projects.vercel.app

@hngngn
Copy link
Owner

hngngn commented Jun 19, 2024

Screen.Recording.2024-06-19.at.11.20.41.mov

@hngngn
Copy link
Owner

hngngn commented Jun 19, 2024

Try to remove this. If it does not solve the problem, then the issue is not with my component but with the library itself.

format={e =>
new Intl.DateTimeFormat("en-US", {
dateStyle: "long"
}).format(new Date(e.toString()))
}

zoutiyx added a commit to zoutiyx/shadcn-solid-date-picker that referenced this issue Jun 19, 2024
@zoutiyx
Copy link
Author

zoutiyx commented Jun 19, 2024

It works expectedly now.

I removed the recommended lines here: https://shadcn-solid-date-picker-1687j1d96-zoutiyxs-projects.vercel.app

@zoutiyx
Copy link
Author

zoutiyx commented Jun 19, 2024

This "fix" resolves the issue. It seems timezone related or an issue with the way the dates are handled in the format function.

format={(e) => {
        const parsedDate = new Date(Date.parse(e.toString()));

        const normalizedDate = new Date(
          parsedDate.getUTCFullYear(),
          parsedDate.getUTCMonth(),
          parsedDate.getUTCDate()
        );

        return new Intl.DateTimeFormat("en-US", {
          dateStyle: "long",
        }).format(normalizedDate);
      }}

See it here: https://shadcn-solid-date-picker-n9nsihjlk-zoutiyxs-projects.vercel.app

hngngn added a commit that referenced this issue Jun 21, 2024
fix: `Date Picker` style
@hngngn hngngn closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants