Datepicker does not close
Datepicker does not close
Hi, I am using the latest Editor version. When using more complex Editor pop ups with many fields and dependencies I get the problem that the date picker doesn't close after selecting a date. It just stays open, if I move the mouse away from the picker it might close after more than 10 seconds. The only way to close it is to hit the tab key.
Would you have an idea how to fix this? How can I force date picker to close when selecting a new date?
Answers
Hi @rf1243 ,
We've not seen that problem - are you able to link to an example that demonstrates it please.
Cheers,
Colin
I will need to set this up for you. Where should I send the credentials for log in etc.? Can't post them here.
ok, will send it in a private message. Probably on Thursday this week.
Send it on to me as a PM please. We are about to do a 1.9.1 release of Editor which changes
datetime
a little, so it might be worth trying that when its available.Allan
ok, that was overlapping Will try 1.9.1 asap.
@allan
I upgraded to the latest data tables release and to Editor 1.9.1. There was no change. I sent you my credentials etc in a private message.
Roland
Thank you for the link. I see the issue on your page - it looks like the
click
event is being cancelled by something before it can bubble up to thebody
element and close the input element.This is the code that Editor uses:
The only way I was able to reproduce the error locally was to use:
to prevent the click event bubbling up.
I'd suggest starting by looking for click event handlers with return false, or use
stopPropagation()
to stop bubbling.Allan
Thanks Allan. Will try a few things and get back to you!
Roland
@allan
I tried many things but nothing worked. Even deleting all the "preventDefaults()" etc. didn't work.
I also noticed that the Editor code that should hide the widget when scrolling doesn't work for me either ... Any ideas?
In this screenshot I marked everything that doesn't work for me.
The only "hide()" that works is the one on "keydown" ...
Its not working because there is something else on the page that it stopping the code for getting that far.
I haven't dug into the code external to Editor, but those events just aren't happening (or rather that are being cut off).
The way I'd approach debugging that myself is to start removing other plug-ins / libraries / event handlers on the page to see what is causing the issue.
Alternatively start from a simple Editor example (since you can see it working on our example pages) and add the other plug-ins / libraries / event handlers you are using to, again, see which one is stopping the event from bubbling.
Allan
Sounds really, really cumbersome. My page has become so complex that I'll probably do nothing (and ask the users to use the tab key if the widget doesn't close) or I'll make my own field type that shows the day of week right next to the date and has no widget.
I noticed that most of my users will type in the dates anyway and not select them with the widget (and that is facilitated with date masking so they only need to type 19102019 instead of 19/10/2019 or 19.10.2019). What most people want to know is the day of week of the entered date to figure out whether they have accidentally picked a week end.
@allan, I removed all of the code relevant for the new product one by one and tested it. No effect. The problem persisted. I was surprised. The problem only occurs when selecting the product "current account". All other products available on the same page work without issues.
I also noticed further Javascript problems when working with "current account":
- My tooltips in the Editor popup do not work any longer
- after making a change the selection of the respective contract and the hiding of the unselected contracts does not work any longer.
I will now remove all of the new code at once and then redo all of the 24 changes for the product one by one. Hopefully this will help.
Is there any faster way?
I removed all of the new Javascript code for the product: NOTHING improved. I am getting a little desparate with this stuff now. What could I do?
Sorry for the delay in getting back to you - I've been off for a few days.
Looking in more detail I think I was wrong about the
stopPropagation
- apologies. The effect did look like that, but actually I think what is happening is that you've got an infinite loop on the page which is making the page run very slow and really hard to debug.Specifically you have:
So if
fixed.first_repayment
changes value, then you dropping into thatsetEditorFirst...
method which does:where
firstRepayment
is thefixed.first_repayment
field. So its setting its own value, which is triggering the change event (it has to even although its actually the same value, since you are specifically calling thefield().set()
method) which calls the dependent method, which calledsetEditorFirst...
, etc. That's killing the page and I think that's resulting in what you are seeing since the browser is taking so long to process the click.I've got an i7 processor in this computer and the fans spin up to max when showing that form, which is a good indication of an infinite loop as well.
Regards,
Allan
Sorry, I lost track myself I am afraid; just saw your reply for the first time! Will check that out asap. There is a lot of dependencies on that page I know - and I have it on my to do list to remove them all and then add them all back and see what happens. The "dependent" feature is great: My clients recognize it as a great advantage over my competitor's more "static" user interface. My clients can do everything in one dialogue and aren't bothered with irrelevant fields and the like - but this great feature obviously has a price ... It's getting difficult for me to deal with the complexity it creates.
Thanks @allan. Will get back asap.
Roland
WOW!!!
@allan, I am impressed!!! Just got rid of that dependency and everything works like a charm!
How were you able to identify that it was just this dependency causing the issue? Did you really check all of them? I have ".dependent" 43 times on that page which made me surrender to be honest ...
When I recorded a JS trace on your page, it was that function that was being hit all the time (in the infinite loop) .
Allan
@allan: This made me wonder:
I thought it would "know" that the value hasn't changed and then not set it again. That's why I never worried about this. I will have to change all of my dependent checks and make sure I only set the value when it is actually required.
The function in the code example above now looks like below. The functionality is the same; I had to add the empty checks for the fields though which inflates the code.
Is there an easier way to do this? If not I will have to add the empty checks to all of my dependency checks.
I also found out why the problem only occurred with the product "current account": It has no regular repayments. Hence the code got triggered in an endless loop while with other products the problem was minor: An endless loop could also have been triggered but it was later in the process so that it basically went unnoticed.
I feel a bit ashamed, @allan. I am obviously not smart enough to do this myself ... Just googled to figure this out but didn't find anything useful. Then tried
chrome://tracing and selected "Javascript and rendering". It did something but I was completely unable to understand any of the results ...
Can you point me in the right direction on how to do this myself please.
I wondered about that as well when I saw what had happened. Honestly, I'm not sure - it is explicit setting the value through the
field().val()
method, so it feels right that the changed event should trigger, but also its not actually changing the value, so on the other hand it shouldn't trigger.I'm not going to change it at the moment as this is the first time I've encountered this I think, but it is something I'm aware of now and will keep an eye on!
Pfft. I just don't have a life . This is a good introduction to profiling Javascript in Chrome. [This also looks useful]https://developers.google.com/web/tools/chrome-devtools/rendering-tools).
Interpreting the results however, is perhaps a different story! The best thing to get used to it is trigger a known action - e.g. submit an Editor form, while recording a profile and then inspect it to see the code pattern that was executed. It just takes time to get used to doing that kind of thing. I guess I have the "advantage" of spending so much time debugging .
Allan
Hi Allan, thanks for the hints regarding Javacript tracing! Your support is excellent as always!
I thought about this for a while:
I would strongly agree to your words in italics: In my opinion the "changed" event should only trigger if something was changed in its content and not if it stayed the same even though its content was overwritten with an identical value! "Changed" must not mean it was NOT changed content wise. Otherwise I will have to live with my work around which is: Avoid setting a field if the value of the field is already the desired value.
This will massively inflate my code! Think about this code with an individual check of each and every field on whether or not it already has the desired value ... 17 additional "if" statements etc.
It would be great if you could think it over, Allan. I am also willing to do a hack until you are ready to integrate this into a regular Editor release - if you could tell me where I would need to put it. Thank you!
To put in a hack workaround, search the Editor code base for
_triggerChange()
- that's the method that is called internally when a field value "changes". You'd need to put a condition around the calls to that method.I've filed a bug for this internally (DD-1210) - if we put it in, it will be the next major version of Editor (1.10?! don't know yet...!) since it could be a breaking change.
Allan
p.s. Thanks for the feedback and your thoughts on this!
@allan: Has this been fixed in the latest Editor version?
I came across the issue again, but I am still using Editor 1.9.3
This is my work around making sure I only make the fewest possible changes to the Editor fields avoiding any "unnecessary" change if the field value hasn't changed.
I use global variables to make sure I only update the select field options if they have changed.
What does this do? I have three planning levels in a certain report (not in all other reports.) The user can pick between 1 and 3 of them. Options and visibility need to be adjusted dynamically depending on how many levels the user chooses and what option for each level.
As you can see the code is unnecessarily inflated because I have to make sure that no editor field setting is done if the field value hasn't changed.
Hi Roland,
Unfortunately, no - this one didn't make it into Editor 2. However, reading over it again I think your suggest is the correct thing to do and I've increased the priority of the issue. It will be fixed in the next release of the DateTime plug-in (which has been split out from Editor now).
Allan
Hi @rf1234.
I lost sight of this one - apologies! I have finally committed the change needed though. I'll release a patch of DateTime when Editor 2.4 drops.
Allan