atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
440 stars 105 forks source link

Prevent JsCallback chain to be evaluated twice #2150

Closed mvorisek closed 8 months ago

mvorisek commented 8 months ago

Since the introduction - https://github.com/atk4/ui/blob/90b0fcecdc/src/jsCallback.php#L21 - the JS chain was allowed to be mutated (like $jquery->xxx()) and if so, it was automatically appended to the response.

But all usages and demos also return the JS chain!

This was a problem, as the returned JS chain was added to the response as well, so the JS chain was evaluated twice!

Now we fix it by longer adding the JS chain to the response, instead, we require the JS chain to be returned it if it was mutated.

repro: https://github.com/atk4/ui/blob/5.0.0/demos/javascript/js.php#L60

before:

image

after:

image