t1m0n / air-datepicker

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

Possible BUG: autoClose: false -> Uncaught TypeError: this.nav is undefined #575

Closed hdijkema closed 7 months ago

hdijkema commented 7 months ago

Could it be that 'this.nav.destroy()' should be 'this.$nav.destroy()' in this piece of code?

this.$content.appendChild(this.views[this.currentView].$el),
            this.$nav.appendChild(this.nav.$el)
          }
          _destroyComponents() {
            for (let e in this.views) this.views[e].destroy();
            this.views = {},
            this.nav.destroy(),
            this.timepicker &&
            this.timepicker.destroy()
          }
hdijkema commented 7 months ago

Sorry, I see now that I need to check the 'visible' property before trying to hide the calendar widget.

let options = {
            locale: AirDatepickerLocale.get(language()),
            //autoClose: true,
            onSelect: function() { 
                if (this.changing) { 
                    this.changing = false;
                    return;
                }
                if (this._pickr.visible) {
                    this._pickr.hide();
                }
                this.onSelect(); }.bind(this),
            toggleSelected: false
        };
hdijkema commented 7 months ago

So, this is no bug.