-
Notifications
You must be signed in to change notification settings - Fork 150
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
JS.push doesn't accept :event props #573
Comments
Hi @simonmcconnell! Ideally, we should have
which would already handle the default target and be equivalent to:
And since now we finally have a way to represent an event with both, the name and the target, using the JS struct, we should probably deprecate support for |
I forgot to mention that currently, we only accept the |
Hi marlus. When you say "as above", are you referring to your ideal future scenario?
|
@simonmcconnell yes! |
Hey @simonmcconnell!
I still think is valuable to add syntactic sugar for
as it's the most common use for it, but the first argument (in this case,
I would not recommend using it as
|
Thanks for taking a look. I'm not sure I follow with respect to setting the options later. Doesn't my dodgy workaround set them when adding the
But that doesn't really help for LiveView source: def push(%JS{} = js, event, opts) when is_binary(event) and is_list(opts) do
opts =
opts
|> validate_keys(:push, [:target, :loading, :page_loading, :value])
|> put_target()
|> put_value()
put_op(js, "push", Enum.into(opts, %{event: event}))
end |
@simonmcconnell I totally misunderstood the whole thing. Thanks for persisting on the issue. I believe we should work on replacing I'm reopening it. Thanks again! |
No problem. Let me know if you want a hand with it. |
Surface:
v0.7.1
LiveView:
v0.17.7
Elixir:
v1.13.3
Try to pass an
event
prop toJS.push
and it will crash on:Workaround
<button phx-click={Surface.JS.push(@some_event, value: %{field: @field})}>button</button>
Should we create a
Surface.JS
and overridepush
?The text was updated successfully, but these errors were encountered: