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

Initial date bug #41

Closed
3nematix opened this issue Jan 5, 2023 · 2 comments
Closed

Initial date bug #41

3nematix opened this issue Jan 5, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@3nematix
Copy link

3nematix commented Jan 5, 2023

When providing max date and not passing any date to keep the placeholder visible when u open the date picker the date will always show 2003 year and no days untill you select a month or another year.

code to reproduce the bug

<script>
    import { DateInput } from 'date-picker-svelte'

    let date;
    let date_string;
    let is_date_valid;
    let max_date = new Date();

    // Atleast 14 years old
    max_date.setDate(max_date.getDate() - 5110);

    $: if (date && is_date_valid) {
        date.setHours(12, 0, 0, 0)
        date.toISOString()
        date_string = date.toISOString().slice(0, 10);
    }
</script>

<input bind:value={date_string} type="date" class="hidden" id="id_birth_date" name="birth_date">
<DateInput bind:value={date} bind:valid={is_date_valid} max={max_date} format="yyyy-MM-dd" placeholder="Select a date"/>
@3nematix

This comment was marked as off-topic.

@probablykasper
Copy link
Owner

Fixed in v2.4.2. If today is outside min/max range, It now shows the date closest to today

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