fix: migrate form error display from phx-feedback-for to used_input?/1#4472
Open
fix: migrate form error display from phx-feedback-for to used_input?/1#4472
Conversation
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
cd6560b to
e42c027
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes premature validation error display by migrating from the deprecated
phx-feedback-for/phx-no-feedbackCSS mechanism to the server-sidePhoenix.Component.used_input?/1pattern 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
mix test test/lightning_web/components/new_inputs_test.exs— 7 new tests passmix test test/lightning_web/live/workflow_live/edit_test.exs:1526— job form error test passesAdditional notes for the reviewer
phx-no-feedbackTailwind variant plugin has been removed — onlyphx-*-loadingvariants remain@fieldwas alwaysnil) — simplified to@errors != []job_form_has_errortest helper now uses Floki DOM traversal instead of the removedphx-feedback-forselectorAI Usage
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)