Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always merge defaultArgs in JS.exec #3499

Merged
merged 1 commit into from
Nov 13, 2024
Merged

always merge defaultArgs in JS.exec #3499

merged 1 commit into from
Nov 13, 2024

Conversation

SteffenDE
Copy link
Collaborator

Fixes #3494.

I don't know why, but when passing "defaults" to JS.exec, we only merged the defaults if there is a "data" property. If someone used

<form phx-submit={JS.push("save")}>
  <button name="foo" value="baz">Submit</button>
</form>

the submitter would be passed as defaults, but the command itself would be ["push", {"event": "save"}], therefore the defaults would not be merged. This commit changes the merging to always happen, but the phxEvent args always override the defaults.

Fixes #3494.

I don't know why, but when passing "defaults" to JS.exec, we only merged
the defaults if there is a "data" property. If someone used

    <form phx-submit={JS.push("save")}>
      <button name="foo" value="baz">Submit</button>
    </form>

the submitter would be passed as defaults, but the command itself would
be `["push", {"event": "save"}]`, therefore the defaults would not be
merged. This commit changes the merging to always happen, but the
phxEvent args always override the defaults.
@chrismccord chrismccord merged commit 93d2424 into main Nov 13, 2024
14 checks passed
@chrismccord chrismccord deleted the sd-issue-3494 branch November 13, 2024 17:34
@chrismccord
Copy link
Member

❤️❤️❤️🐥🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

phx-submit="save" behaves differently to phx-submit={JS.push("save")}
2 participants