katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

Datepicker inside a modal window causes modal to close #55

Closed gromon42 closed 7 years ago

gromon42 commented 7 years ago

Hey,

I have an issue in my app, i have 2 inputs in which i'm getting the values of your datepickers but when i pick a date too quickly and then try to click on the other input field then it causes my current modal to close itself.

I've checked online for a quick fix but nothing seems to match my current problem. Maybe adding some setTimeOut on the Ok button validation will fix the problem but that is not the best way to handle things in my opinion.

Looking forward to hear if you got the same problem at some point

katemihalikova commented 7 years ago

Hi Gaultier, could you please make up a codepen/plnkr/jsbin demonstrating your problem? Thanks!

neolectron commented 7 years ago

Here's the problem. I know its not only about your dateTimePicker but its the same bug. So it directly affect your work. http://codepen.io/anon/pen/KrxRXx

--- instruction : open a modal -> open an alert/popup -> close and QUICKLY click anywhere on the modal. It will cause the modal to close itself too.

gromon42 commented 7 years ago

Yes that is exactly the bug that i'm having actually ! I ve also just seen your latest issue posted on the ionic framework and it doesnt seem to have a fix for it just yet. But yeah it would be nice if we could find a solution all together because this is happening with all popups/alert/confirm.

katemihalikova commented 7 years ago

Thanks!

The bug lays in ionic. AFAIK their backdrops are separate entities and clicking on a backdrop closes the topmost entity. When the popup is being hidden, the backdrop already knows that the topmost entity is now the modal, but the backdrop is still clickable until its animation ends. When the backdrop is clicked in such situation, the modal is closed, because backdrop service doesn't know that the backdrop is being hidden and shouldn't be clickable.

You can watch and :+1: driftyco/ionic#5869 issue that should solve that. Workaround for now is to set backdropClickToClose: false in modal options object.

I'm going to close this issue as the problem lays in framework code and workaround exists.