Skip to content

Commit

Permalink
consider any touched input as not _unused_ (#3237)
Browse files Browse the repository at this point in the history
* consider any touched input as not _unused_

* give event_test assert_receive more time
  • Loading branch information
SteffenDE committed May 10, 2024
1 parent 4643fc1 commit da4ba6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ let serializeForm = (form, metadata, onlyNames = []) => {
let elements = Array.from(form.elements)
for(let [key, val] of formData.entries()){
if(onlyNames.length === 0 || onlyNames.indexOf(key) >= 0){
let input = elements.find(input => input.name === key)
let isUnused = !(DOM.private(input, PHX_HAS_FOCUSED) || DOM.private(input, PHX_HAS_SUBMITTED))
let inputs = elements.filter(input => input.name === key)
let isUnused = !inputs.some(input => (DOM.private(input, PHX_HAS_FOCUSED) || DOM.private(input, PHX_HAS_SUBMITTED)))
if(isUnused && !(submitter && submitter.name == key)){
params.append(prependFormDataKey(key, "_unused_"), "")
}
Expand Down
2 changes: 1 addition & 1 deletion test/phoenix_live_view/integrations/event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ defmodule Phoenix.LiveView.EventTest do
end}
)

assert_receive {:DOWN, _ref, :process, ^pid, _reason}
assert_receive {:DOWN, _ref, :process, ^pid, _reason}, 500
end) =~ "Got: {:reply, :boom"
end

Expand Down

0 comments on commit da4ba6b

Please sign in to comment.