t1m0n / air-datepicker

Lightweight, dependency-free JavaScript datepicker.
https://air-datepicker.com
MIT License
2.58k stars 1.36k forks source link

API weirdness #581

Closed scriptingstudio closed 5 months ago

scriptingstudio commented 5 months ago

While testing API I create a new button

let buttonOK = {
    content: 'OK',
    className: 'custom-button',
    onClick: (dp) => {
        dp.hide();
        dp.done();
    }
}

After click on the button the console error comes up

Uncaught TypeError: dp.done is not a function
at onClick 
at HTMLButtonElement.<anonymous> (air-datepicker.js:1:19640)

If I use just dp.done; it will work without errors, although the doc states to use done as function. Is it a possible bug or what?

t1m0n commented 5 months ago

Hello! There is no such method and that is why you get an error. Maybe there is an error in documentation, could you please tell me where did you find about the need to use this method?

scriptingstudio commented 5 months ago

image

t1m0n commented 5 months ago

@scriptingstudio done here is a callback which is passed through parent function argument and is not a method of AirDatepicker. Also it is used only in such situation when you need to control position manually.

scriptingstudio commented 5 months ago

Should I use done in a button handler after hide() or just hide()?

t1m0n commented 5 months ago

@scriptingstudio No, you should not