Skip to content

fix: migrate form error display from phx-feedback-for to used_input?/1#4472

Open
stuartc wants to merge 2 commits intomainfrom
fix/migrate-used-input
Open

fix: migrate form error display from phx-feedback-for to used_input?/1#4472
stuartc wants to merge 2 commits intomainfrom
fix/migrate-used-input

Conversation

@stuartc
Copy link
Member

@stuartc stuartc commented Feb 26, 2026

Description

This PR fixes premature validation error display by migrating from the deprecated
phx-feedback-for / phx-no-feedback CSS mechanism to the server-side
Phoenix.Component.used_input?/1 pattern introduced in LiveView 1.0.

The old client-side attributes became inert in LV 1.0, causing errors like
"can't be blank" to appear on fields the user hasn't interacted with yet.

Validation steps

  1. Open any form with required fields (e.g. new Channel modal, new Credential)
  2. Interact with one field only — confirm errors do NOT appear on untouched fields
  3. Interact with a required field and clear it — confirm the error appears
  4. Submit the form with missing required fields — confirm all errors appear
  5. Run mix test test/lightning_web/components/new_inputs_test.exs — 7 new tests pass
  6. Run mix test test/lightning_web/live/workflow_live/edit_test.exs:1526 — job form error test passes

Additional notes for the reviewer

  1. The phx-no-feedback Tailwind variant plugin has been removed — only phx-*-loading variants remain
  2. Password input had a dead-code error condition (@field was always nil) — simplified to @errors != []
  3. The job_form_has_error test helper now uses Floki DOM traversal instead of the removed phx-feedback-for selector

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

@github-project-automation github-project-automation bot moved this to New Issues in Core Feb 26, 2026
@stuartc stuartc self-assigned this Mar 3, 2026
stuartc added 2 commits March 3, 2026 12:18
Phoenix LiveView 1.0 removed the client-side phx-feedback-for/phx-no-feedback
CSS mechanism. Replace with the server-side used_input?/1 check so validation
errors only appear on fields the user has interacted with.

- Gate error extraction on used_input? in input/1, errors/1, old_error/1,
  and custom error_field/1 components
- Remove all phx-feedback-for attributes and phx-no-feedback:* CSS classes
- Remove phx-no-feedback Tailwind variant plugin
- Fix dead code in password input error condition
- Update job_form_has_error test helper selector
- Add component-level tests for used_input? gating
@stuartc stuartc force-pushed the fix/migrate-used-input branch from cd6560b to e42c027 Compare March 3, 2026 10:19
@stuartc stuartc marked this pull request as ready for review March 3, 2026 10:19
@stuartc stuartc moved this from New Issues to In review in Core Mar 3, 2026
@stuartc stuartc added the bug Newly identified bug label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Newly identified bug

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant