Skip to content

DisabledDates function is not called at first rendering in MonthPicker #1070

Closed
@ashab20zakaraev

Description

@ashab20zakaraev

Describe the bug
Props disabledDates using the function does not work as expected.

To Reproduce
Simple code to reproduce the problem:

<template>
    <div class="wrapper">
        <Datepicker 
        v-model="selectedDate" 
        month-picker 
        :disabled-dates="isDisabledMonth" 
        placeholder="Select Date" />
    </div>
</template>

<script lang="ts" setup>
    import { ref } from 'vue';
    import Datepicker from '../src/VueDatePicker/VueDatePicker.vue';

    const selectedDate = ref();

    const allowedMoths = [
        "2024-04-30",
        "2024-05-31"
    ]

    function isDisabledMonth(date) {
        const month = new Date(date).toISOString().split("T")[0];

        console.log(date)

        return !allowedMoths.includes(month)
    }
</script>

<style lang="scss">
    .wrapper {
        padding: 200px;
    }
</style>

By running this code, you can verify that log is not called in the isDisabledMonth method.

Expected behavior
The function to be called on the first rendering and subsequent year changes in the calendar returning each date

Screenshots
I think the problem may be in the isMonthDisabled method in the date-utils file, as it doesn't handle the case if disabledDate function and accordingly it is not called.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions