themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.74k stars 727 forks source link

Datepicker doesn't hide on date selection with autohide true #708

Closed aroncal closed 3 months ago

aroncal commented 11 months ago

Describe the bug Datepicker doesn't hide on date selection ('onChangeDate' event) with autohide=true.

Expected behavior It should hide.

Desktop (please complete the following information):

Additional context Inspecting /node_modules/flowbite-datepicker/dist/js/datepicker-full.js I see this 'hide' function:

    hide() {
      if (!this.active) {
        return;
      }
      this.datepicker.exitEditMode();
      this.element.classList.remove('active', 'block');
      this.element.classList.add('active', 'block', 'hidden');
      this.active = false;
      triggerDatepickerEvent(this.datepicker, 'hide');
    }

I think the line in which classes are added, 'active' and 'block' shouldn't be there. If I remove them, it works as expected, like this:

    hide() {
      if (!this.active) {
        return;
      }
      this.datepicker.exitEditMode();
      this.element.classList.remove('active', 'block');
      this.element.classList.add('hidden');
      this.active = false;
      triggerDatepickerEvent(this.datepicker, 'hide');
    }
zoltanszogyenyi commented 3 months ago

Hey @aroncal,

We pushed a new update with v2.4.1 for the datepicker. Please check the upgraded API and examples:

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

Cheers, Zoltan