Skip to content

Commit 8cf8160

Browse files
nhobesclaude
andcommitted
Fix used_input? implementation and update test
- Replace incorrect pc_used_input? implementation with Phoenix.Component.used_input? - Update dual range slider error test to include field in params - All tests now passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 37fbb3e commit 8cf8160

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

lib/petal_components/field.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ defmodule PetalComponents.Field do
122122

123123
# When a FormField struct is provided, normalize and delegate rendering.
124124
def field(%{field: %Phoenix.HTML.FormField{} = field} = assigns) do
125-
errors = if pc_used_input?(field), do: field.errors, else: []
125+
errors = if used_input?(field), do: field.errors, else: []
126126

127127
assigns
128128
|> assign(field: nil, id: assigns.id || field.id)
@@ -978,8 +978,4 @@ defmodule PetalComponents.Field do
978978
end
979979
end
980980

981-
# Renamed helper to avoid conflict with Phoenix.Component.used_input?/1
982-
defp pc_used_input?(field) do
983-
field.errors != []
984-
end
985981
end

test/petal/field_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ defmodule PetalComponents.FieldTest do
950950
field: :price_range,
951951
id: "price_range",
952952
form: %Phoenix.HTML.Form{
953-
params: %{},
953+
params: %{"price_range" => nil},
954954
source: %{},
955955
impl: Phoenix.HTML.FormData.Ecto.Changeset,
956956
name: "filter"

0 commit comments

Comments
 (0)