michael-hack/bulma-calendar

clear() doesn't clear the input field

Closed this issue · 1 comments

If I programmatically call the clear() function, it clears the internal date structure, but nut the input field.
If I click on the clear button (cross) on the right edge of the input field it works as expected.

How to clear completely the datetimepicker (internal data structure + input field)??

ready(function () {
        target_time = bulmaCalendar.attach('#target_time', {
            displayMode: 'dialog',
            dateFormat: "yyyy-MM-dd",
            lang: 'hu'});
    });
...
    function toggleModal(modal) {
        var Modal = document.querySelector(`#${modal}`);

        document.getElementById("base_val").value = 168;
        document.getElementById("db").value = "";
        document.getElementById("target_time").value = "";
        target_time[0].clear();
        target_time[0].refresh();
        Modal.classList.toggle('is-active');
    };

Fixed.

The original idea behind this was that a clear() must be followed by a save() to apply the change to the input. However, this makes little sense with a closed picker, so I have now changed this.