Skip to content

Prevent JsCallback chain to be evaluated twice#2150

Merged
mvorisek merged 3 commits intodevelopfrom
fix_js_callback
Jan 30, 2024
Merged

Prevent JsCallback chain to be evaluated twice#2150
mvorisek merged 3 commits intodevelopfrom
fix_js_callback

Conversation

@mvorisek
Copy link
Copy Markdown
Member

@mvorisek mvorisek commented Jan 30, 2024

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 no 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

@mvorisek mvorisek marked this pull request as ready for review January 30, 2024 22:34
@mvorisek mvorisek changed the title Prevent JsCallback chain to be returned twice Prevent JsCallback chain to be evaluated twice Jan 30, 2024
@mvorisek mvorisek merged commit 9f5104c into develop Jan 30, 2024
@mvorisek mvorisek deleted the fix_js_callback branch January 30, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant