Skip to content

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 showing 0 (or 0,00, 0.0) empties when it gains focus, so typing 1 gives 1 rather than 10. Leaving it empty puts the zero back; typed text stays. A host’s own onfocus/onblur/onkeydown are 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 a phx-focus handler 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). An onkeydown handler restores it before the implicit submit.
  • A readonly zero 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 an input event, so the server stops holding "" while the field shows 0. 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.