kodaicoder / svelte-flatpickr-plus

A flatpickr datepicker in svelte components
https://svelte-flatpickr-plus.vercel.app
7 stars 3 forks source link

Lost chevron with "yearDropDown" #3

Closed frck006 closed 1 year ago

frck006 commented 1 year ago

Hi

Do you know why sometime I lost chevron with "yearDropDown" ?

image

I put 2 dates pickers in differents position in my page and one is ok, other no.

When I inspect the page, I see differents but I don't understand why: The second with "arrowUp/arrowDown" doesn't work. image

If you have an idea... :)

PS: I use svelte carbon, perhaps their css are responsable.

Regard

frck006 commented 1 year ago

I found. I was using a props to pass a 'handleChange' function to my "DatePicker". Now I use a "dispatch" to send the information back to the parent. I don't know why but there is no more problem.

kodaicoder commented 1 year ago

Can you show me a code that have problem ?

kodaicoder commented 1 year ago

btw for a note you can using on directive to catching event of hook using hook name too. e.g.

<input
    name="datepickerOnDirectiveDate"
    use:datePicker={dateOptions}
    on:change={changeHandler}
    on:open={openHandler}
    on:close={closeHandler}
    readonly
/>

or you can see a demo here

frck006 commented 1 year ago

In fact, I've always a problem.

I want to set date programaticaly, and for this, I need to get "flatpickr" instance. I write this code, but the first time, "fp" is undefined. :(

` const getFlatpickr = (id: string): Instance | undefined => {

    if (!id) return undefined

    const fps = flatpickr(`#${id}_input`, options)

    const fp = Array.isArray(fps) ? fps[0] : fps

    return fp

}

`

frck006 commented 1 year ago

Ok, I think I found my problem. It's thank to your help, with here

The problem was with calling "flatpickr" without the 3rd argument plugins = [new yearDropdownPlugin()]

And this example: "Date picker with flatpickr element binding" give me the solution with bind:this={datepickerElement} Now, I can get the good "flatpickr": datepickerElement._flatpickr

Regard.