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

Can't unset from and to dates on DatePicker range #1862

Open
JOldak opened this issue Dec 13, 2023 · 0 comments
Open

Can't unset from and to dates on DatePicker range #1862

JOldak opened this issue Dec 13, 2023 · 0 comments

Comments

@JOldak
Copy link

JOldak commented Dec 13, 2023

Hi all,

Using the DatePicker in range mode, I want to be able to unset the values when the user clicks a button (which clears an entire form of page filters).

Unfortunately doing the obvious thing of setting valueFrom and valueTo to "" doesn't work - what happens is that they both end up being set to whatever the valueTo was set to.

After a bit of digging around in the code, it looks like this is happening in the afterUpdate function in DatePicker.svelte. Here:

        // workaround to remove the default range plugin separator "to"
        inputRef.value = $inputValueFrom;

This seems like a valid workaround to prevent the From box showing " to " when there are some values set. However it seems to break things if there is no value set.

My workaround for the workaround is simply to only do the workaround if the value isn't "", like this:

        // workaround to remove the default range plugin separator "to"
        if ($inputValueFrom != "") {
            inputRef.value = $inputValueFrom;
        }

I don't know if this is a sensible/correct fix, but it seems to work for me!

Is there any chance that this fix could be incorporated into the official code?

Thanks!

Joe

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

1 participant