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: input type=date clears on Firefox when invalid date is typed #26175

Closed
vasa-chi opened this issue Feb 16, 2023 · 12 comments
Closed

Bug: input type=date clears on Firefox when invalid date is typed #26175

vasa-chi opened this issue Feb 16, 2023 · 12 comments
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@vasa-chi
Copy link

If you input incorrect value in date input on Firefox, the whole input clears. I've prepared a sandbox: https://codesandbox.io/s/cold-dawn-ksmgb4 . If you input 0 into any part (day, month, year) of the field, it goes to empty state.

React version: 18.2.0
Firefox: 110.0 macOS

Steps To Reproduce

  1. Fill date input with correct value
  2. Enter 0 into it
  3. The whole field clears

Link to code example: https://codesandbox.io/s/cold-dawn-ksmgb4

The current behavior

The field clears

The expected behavior

The field should behave the same as uncontrolled HTML input behaves (specifically, Firefox fills the date part with zeroes).

@vasa-chi vasa-chi added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Feb 16, 2023
@kalp2525
Copy link

This is by-default feature of input type=date, when your type=date so it's validate first and then display. So your input is 0 then validator check the given value is true or if false then it will print perfect date either it will print simple dd-mm-yyyy .

@vasa-chi
Copy link
Author

vasa-chi commented Feb 22, 2023

It isn't by default, and date inputs don't do that. You can play with it on MDN and see for yourself.

This is how Firefox handles 0 in month:
изображение

Input's value in this state is "".

@kalp2525
Copy link

This MDN given by you which was working perfect into my Firefox browser. I don't know why this not working in your Firefox browser. Please see the version of your browser and update it.

@vasa-chi
Copy link
Author

@kalp2525 What do you get, when you input 0 in month part of the input?

@kalp2525
Copy link

image
I getting this when my input 0 in month

@vasa-chi
Copy link
Author

I've checked FF 110.0 on macOS and Windows. Both give me this:
изображение

Maybe this behaviour is locale-related? I'm on ru_RU

@kalp2525
Copy link

I have FF 110.0 same like you so you check again and solve this issue.

@jbonzohln
Copy link

This is happening for me as well. Here is a code sample https://github.com/jbonzohln/react-date-test
I'm using Firefox 123 on macos 14.3.

@jtguignard
Copy link

@jbonzohln
Copy link

That works only if the date input is bound to a single value like you have there, but if it's bound to a field within an object the issue is there. See https://codesandbox.io/p/sandbox/ecstatic-jerry-78z6dw

Copy link

github-actions bot commented Jul 4, 2024

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Jul 4, 2024
Copy link

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
4 participants