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

Handle nullable date. #1

Closed
GioPat opened this issue Nov 22, 2021 · 12 comments
Closed

Handle nullable date. #1

GioPat opened this issue Nov 22, 2021 · 12 comments

Comments

@GioPat
Copy link

GioPat commented Nov 22, 2021

The library already allows null values, but when I pass to the DateInput I get this error:

image

Is there any way to add an element that removes the date from the picker?
Asking this cause my date field is nullable.

@probablykasper
Copy link
Owner

Null values are not allowed. The value argument can be undefined since it's optional, but the value itself can only be Date.

Not quite sure how this should be implemented 🤔 If value is Date | null, then I assume binding to a Date value wouldn't work.

@GioPat
Copy link
Author

GioPat commented Nov 22, 2021

Even with the undefined value, I can't manage to have an empty date

@probablykasper
Copy link
Owner

The argument can be undefined since it's optional and defaults to new Date(), however the value cannot

@GioPat
Copy link
Author

GioPat commented Nov 23, 2021

Saw that the fallback of undefined is new Date(), in fact there is no way of having a null value for the input. How do you handle the case of a nullable date input field?

@probablykasper
Copy link
Owner

Once again, the value cannot be null, there's no way for it to have a value other than Date. This is why I was wondering how to implement it.

@GioPat
Copy link
Author

GioPat commented Nov 23, 2021

I see that the value cannot be null. But I suppose the null can be implemented since the default html 5 input type date supports null value

@probablykasper
Copy link
Owner

That's why I was wondering how to implement it. The HTML date input is not even a Date though, and it's null value is an empty string.

@GioPat
Copy link
Author

GioPat commented Nov 24, 2021

I suppose it can be handled with the empty string.

@nimser
Copy link

nimser commented Jan 4, 2022

I think issue #3 is related to this.
Say you want to load the component without a date, showing the placeholder value of -- / -- / ----. Currently you can't do it, since the whole placeholder thing does not work as the component loads with a default value set to the current date in the code below:

export let value = defaultDate

@mlandisbqs
Copy link

would like to vote for this issue - this was a blocker my team to adopt this date picker component. otherwise it's the best one i've seen so far.

@mkelandis
Copy link
Contributor

Working on a PR for this - it's still a draft and needs some further tweaks, and regression and logging cleanup
https://github.com/mkelandis/date-picker-svelte/pull/1/files?diff=unified&w=1

@probablykasper
Copy link
Owner

Fixed by #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants