Skip to content

Commit

Permalink
Fix upload form recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Sep 19, 2023
1 parent 448bc4f commit 16c04a8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,10 @@ export default class View {
let inputs = Array.from(form.elements).filter(el => DOM.isFormInput(el) && el.name && !el.hasAttribute(phxChange))
if(inputs.length === 0){ return }

// we must clear tracked uploads before recovery as they no longer have valid refs
inputs.forEach(input => input.hasAttribute(PHX_UPLOAD_REF) && LiveUploader.clearFiles(input))
let input = inputs.find(el => el.type !== "hidden") || inputs[0]

let phxEvent = form.getAttribute(this.binding(PHX_AUTO_RECOVER)) || form.getAttribute(this.binding("change"))
JS.exec("change", phxEvent, view, input, ["push", {_target: input.name, newCid: newCid, callback: callback}])
})
Expand Down

0 comments on commit 16c04a8

Please sign in to comment.