michael-hack / bulma-calendar

Bulma's extension to display a calendar
MIT License
286 stars 165 forks source link

TypeError after calendar Destroy - this._ui is null Error v6.1.18 #315

Open Krzyshio opened 1 year ago

Krzyshio commented 1 year ago

Your issue may already be reported! Please search on the issue track before creating one.

Bug Report

Environment

Current Behavior When destroying calendar component, an error "TypeError: this._ui is null" is thrown in the document onclick event handler "onDocumentClickDateTimePicker".

The issue is present in versions above 6.1.0, but switching to version 6.1.0 solves the problem.

Possible Solution I guess that I can debug and fix this problem and I'm happy to do it, but first please please confirm that this is indeed the problem and not me doing something wrong :)

Additional context/Screenshots

image

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Codesandbox with example

You can change bulma-calendar version to 6.1.0 in package.json and the problem disappears

michael-hack commented 1 year ago

You are welcome to look at it, but simply copying the old 6.1.0 passage will not do the trick.

The problem is that the original DOM element is modified by the calendar and would have to be restored to its old state in a destroy(). Previously the "destroyed" element was left in an undefined state, now it is deleted from the DOM on a destroy(). Therefore, a new attach() does not work, because the element no longer exists.

What's wrong with showing and hiding the element with a simple show() / hide()? These functions are made for that.