flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

datepicker listens to 'changeDate' instead of 'change'

Open fabiot21 opened this issue 2 years ago • 2 comments

Describe the bug When using svelte with flowbite datepicker, I am trying to bind the value from the user input to the component. But the problem is that the datepicker.js handles onChangeDate instead of a standard DOM onChange. So typescript gives me error when implementing the function.

The ts error is:

Argument of type '{ name: string; type: "text"; class: string; placeholder: string; "on:changeDate": (e: any) => void; value: string; }' is not assignable to parameter of type 'HTMLProps<"input", HTMLAttributes<any>>'.
  Object literal may only specify known properties, and '"on:changeDate"' does not exist in type 'HTMLProps<"input", HTMLAttributes<any>>'.ts(2345)

To Reproduce Steps to reproduce the behavior:

  1. Init a svelte project
  2. import datepicker.js
  3. use the input flowbite datepicker
  4. try to handle user input using "on:changeDate={(e) => inputDate = e.target.value}"

Expected behavior The expected behaviour is that datepicker.js listens to "change" instead of "changeDate"

Additional context I might be wrong but flowbite-svelte should be having the same problem.

fabiot21 avatar Feb 14 '23 15:02 fabiot21

@fabiot21 Have you found a work around?

puruzio avatar Nov 21 '23 16:11 puruzio

nope, i ended up creating my own datepicker

fabiot21 avatar Nov 21 '23 17:11 fabiot21

Hey everyone,

We have made a big update to the datepicker API that allows you to change and set dates, amongst other things:

https://flowbite.com/docs/components/datepicker/#javascript-behaviour

Cheers, Zoltan

zoltanszogyenyi avatar Jun 27 '24 10:06 zoltanszogyenyi