PhoenixKit 2.37.4: Zero clears itself in decimal fields
PhoenixKit 2.37.4 makes decimal fields easier to fill in. A field that shows 0, 0,00 or 0.0 now empties when it gets focus, so typing 1 gives 1 and not 10.
Leaving the field empty puts the zero back, and anything typed stays. The cleared zero survives page updates while the field has focus, pressing Enter in a just-cleared field submits the zero, and a read-only field is left alone. When the zero is restored, the form’s change event fires, so the server no longer holds an empty value while the field shows 0. A host’s own focus, blur and key handlers still run, after the component’s.
The change applies to every form that uses the <.decimal_input> component.
Full release notes: PhoenixKit 2.37.4
2.37.4 · 22 September 2026
Changed
- A zero in
<.decimal_input>clears itself on focus (#859). A field showing0(or0,00,0.0) empties when it gains focus, so typing1gives1rather than10. Leaving it empty puts the zero back; typed text stays. A host’s ownonfocus/onblur/onkeydownare chained after the component’s inline handlers, not dropped.
Fixed
- The cleared zero survives LiveView patches (#859 review). It was
parked in a
data-attribute, which LiveView strips from a focused input on every re-render, so aphx-focushandler or any update during focus left the field empty for good. It now lives in an element property. - Enter in a just-cleared zero field submits the zero, not
""(#859 review). Anonkeydownhandler restores it before the implicit submit. - A
readonlyzero field is no longer blanked on focus (#859 review). - Typing then erasing in a cleared zero field tells
phx-change(#859 review). The restore now dispatches aninputevent, so the server stops holding""while the field shows0. An untouched focus/blur still fires nothing.
PhoenixKit 2.37.4. Install or update: {:phoenix_kit, "~> 2.37"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.