atk4/ui

Lookup default value is breaking canLeave

mkrecek234 opened this issue · 9 comments

I have a fairly complex View including tabs, and inside the tabs I have a form which itself consists of Accordions and many default fields. The form is configured to have $form->canLeave = false. However, since recently, the onLeave feature does not work properly. Sometimes, the browser warns always, even though nothing was changed in the form. Sometimes, the browser does not warn at all.

Unfortunately, I cannot reproduce this at all currently.

Michael, we need a repro. I advise to record your screen and do as many experiments (and /w different browsers, cleaned cache, ...) as you can. Once you reproduced it, go back to the recorded video and try to simplify/identify the repro steps.

Issue without repro steps is useless.

@mvorisek I agree, but I could not drill down the influencing factors which trigger the canLeave to fail, so hard to produce simplified code that reproduces the issue.

Can you reproduce it at least localy? If yes, feel free to send me a video in PM and I can try to figure it out.

Yes, canLeave started to fail at the time when I posted the issue. We can do a local screen share if you like - here is a video based on current develop branch - for data protection reasons I cannot share the headline, I am clicking on another menu item or crumb link and in between I am reloading the browser window. As you can see always it assumes something has changed in the form, so the pop-up comes up even though I did not change anything:

Bildschirmaufnahme.2023-06-19.um.18.28.07.mov

Sometimes, the browser does not warn at all.

Very important claim, am I right that you can reproduce it repeatably using same sequence of steps (ie. no race condition issue)?

it assumes something has changed in the form, so the pop-up comes up even though I did not change anything

press F12 in browser and in the Debugger tab place a breakpoint at this line https://github.com/atk4/ui/blob/c093efc087/js/src/services/form.service.js#L53

it should be evident what control causes the form to be dirty

Please also note that currently changing the value back does not make the form non-dirty - can you confirm this is not the issue you face?

Also note that if you click "Auf Seite Bleiben", nothing is done and the page is not reloaded, I expect no dirtiness change - is that true? (or is clearDirtyForm in the JS called?)

@mvorisek Thank you for the instruction - I had now a form where with every reload (and no form change), the prevenLeave modal is opened. So I can reproduce it at least for this single view constantly. Putting the breakpoint where you described and loading the view, it immediately halts at the mentioned line 53. The t.data("isDirty", !0) is as follows - unfortunately I cannot figure out where the issue is.

Based on the chat discussion, the problem of this issue is solely in: https://github.com/atk4/ui/blob/67cfdbd00d/src/Form/Control/Lookup.php#L392

@mvorisek Thank you for helping to find the causing element for the issue. Fixed by PR #2092