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

current day remain selected even if you change date #15

Open
Mat-tlb opened this issue Aug 4, 2021 · 3 comments
Open

current day remain selected even if you change date #15

Mat-tlb opened this issue Aug 4, 2021 · 3 comments

Comments

@Mat-tlb
Copy link

Mat-tlb commented Aug 4, 2021

i notice that even if i change date on the calendar the current day remain higlithed with the custom background.

i want to disable this for user friendly questions

i'm using this plugin for a chek-in/check-out component.

Also it is possible to start another calendar and setting the current day to the next day based on the selected day of the previous calendar?

@jaredgibb
Copy link

Also it is possible to start another calendar and setting the current day to the next day based on the selected day of the previous calendar?

You should be able to add a change listener to the calendar and set the default date of the second calendar through the change event by grabbing the current date of the first calendar and adding some period of time to it.

@afzalzbr
Copy link

I'm facing the same issue that the current date still remains active when I choose any other date than today.
Is there any fix for it?

@makivlach
Copy link

makivlach commented Aug 25, 2021

EDIT:

It seems my original post have worked until the display: none was applied. The calendar widget probably just can't handle that style. So another workaround is to apply this style intead of display: none or visibility: hidden and just toggle it to show or hide:

CSS

.size-invisible {
    width: 0;
    height: 0;
    overflow: hidden;
}

Original post:

The problem seems to be caused by setting any kind of invisible style (display: none or visibility: hidden) on the container element node. The calendar does probably some kind of initialization during which the element must stay visible.

As an ugly workaround - you can set opacity: 0 to the calendar container and setTimeout to disable opacity after set amount of time (after the initialization is probably finished) and just let the calendar be display: none normally. E.g.:

HTML

<div id="calendar" class="opacity-1"></div>

JS

let calA = new Calendar({
        id: "#calendar",
        theme: "glass",
        weekdayType: "long-upper",
        startWeekday: 1,
        monthDisplayType: "long",
        headerBackgroundColor: "#b5b5b5",
        calendarSize: "small",
        layoutModifiers: ["month-left-align"],
        dateChanged: (currentDate, events) => {
            console.log('Clicked!')
        },
        monthChanged: (currentDate, events) => {
            console.log("month change", currentDate, events);
        }
    });

    setTimeout(() => {
        $('#calendar').toggleClass('invisible').toggleClass('opacity-100')
    }, 100)

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

4 participants