i-n-g-m-a-r
What is the expected behaviour of "phx-blur" on an input?
Steps:
- email input component is rendered for the first time, the email input field receives focus
- I click somewhere outside of the component, NOT the button, the email input field loses focus (blur)
- email input field does not have focus, blur event is in the past.
- I click the next button, blur-handler receives
%{"value" => "Next"}
Is this expected behaviour?
I would expect the value in the blur-handler always to be that of the email input field.
In my mind the value of the button should be completely unrelated to the “blur”, because the button “click” did not cause the “blur”.
Render component:
def render(assigns), do: ~L"""
<div id="<%= assigns.id %>">
<ul>
<li><%= email_input(assigns) %></li>
<li><%= next_button(assigns) %></li>
</ul>
</div>
"""
defp email_input(assigns), do:
Phoenix.HTML.Tag.tag :input, [
type: "email",
name: "email",
value: assigns.state.value,
autofocus: true,
"phx-blur": "blur",
"phx-target": assigns.myself
]
defp next_button(assigns), do:
Phoenix.HTML.Tag.tag :input, [
type: "button",
value: "Next",
"phx-click": "next",
"phx-target": assigns.myself
]
Blur handler:
def handle_event("blur", %{"value" => expect_email_input_value}, socket) do
IO.inspect expect_email_input_value, label: "blur" # <-- blur: "Next"
{:noreply, socket}
end
How does the button value end up in my email input field blur handler ?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 4 of 4 Posts
i-n-g-m-a-r
Update, it’s not the blur, it’s very weird though.
Not sure whether the problem exists between my computer and chair.
I have stripped down my component to a working example, see below.
Result is: click, click, boom.
After the third click, as soon as render_error/1 returns a list item, the value of the email input is set to “Next”.
After the fourth click, the list item has been removed and the value is “” again.
The value setting in the state is always “”.
Console output:
This is the component:
i-n-g-m-a-r
https://github.com/phoenixframework/phoenix/issues/3877
sfusato
It’s not set to “Next” actually. “Next” is hard-coded in the message, but not the output of the value:
From the console output you copy-pasted above the value is still empty on your 3rd click:
Value is still
value: \"\". I’m not seeing it set as “Next” unless I’m missing something.i-n-g-m-a-r
tnx @sfusato I responded on github.