You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using TinyDatePicker on a Bootstrap Offcanvas element which is basically like a modal dialog appearing from the edge of the screen. It has a sensible default behavior of closing itself when user clicks outside of the Offcanvas element.
For some reason, when clicking on any TinyDatePicker element then event.target node does not seem to be in a DOM tree anymore. Offcanvas performs offcanvasEl.contains(event.target) (Node#contains) on each click event and since it returns false by the reason explained above then offcanvas element will be always closed on any click on TinyDatePicker.
I've also used appendTo option for TinyDatePicker and I can see that the created picker is inside of my offcanvas element.
Clicking on any other element on offcanvas element prints out the whole tree up to html element.
I have a suspicion that TinyDatePicker will remove itself from DOM too soon - it should do it in the next JavaScript event loop cycle (via setTimeout(0) for example) to avoid this kind of problems. Just to clarify that this problem is not offcanvas specific, but any component specific, which wants to check where click exactly happened.
This is the ugly hack how I can solve this currently if anyone else happens to stumble on the same problem:
I'm using
TinyDatePicker
on a Bootstrap Offcanvas element which is basically like a modal dialog appearing from the edge of the screen. It has a sensible default behavior of closing itself when user clicks outside of theOffcanvas
element.For some reason, when clicking on any
TinyDatePicker
element thenevent.target
node does not seem to be in a DOM tree anymore.Offcanvas
performsoffcanvasEl.contains(event.target)
(Node#contains) on eachclick
event and since it returnsfalse
by the reason explained above then offcanvas element will be always closed on any click onTinyDatePicker
.I've also used
appendTo
option forTinyDatePicker
and I can see that the created picker is inside of my offcanvas element.This is how I'm creating TinyDatePicker:
And this is how I can verify that
TinyDatePicker
is within myoffcanvas
element:Opening
TinyDatePicker
element results in the output of printing out DOM tree up tohtml
element including the expectedoffcanvas
element.And this is how I can verify that
TinyDatePicker
clicked target is not within my offcanvas element anymore:Clicking on any
TinyDatePicker
element results with the following output:Clicking on any other element on
offcanvas
element prints out the whole tree up tohtml
element.I have a suspicion that
TinyDatePicker
will remove itself from DOM too soon - it should do it in the next JavaScript event loop cycle (viasetTimeout(0)
for example) to avoid this kind of problems. Just to clarify that this problem is notoffcanvas
specific, but any component specific, which wants to check where click exactly happened.This is the ugly hack how I can solve this currently if anyone else happens to stumble on the same problem:
The text was updated successfully, but these errors were encountered: