From d8f85b03adde877765b6fc9744413c9c865d6def Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Fri, 10 Jul 2026 16:42:56 +0200 Subject: [PATCH] fix: use getElementById for relink FilePond pool lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FilePond 4.x wraps the original input element in its own DOM structure which can break CSS attribute selectors. querySelector with .tfe-file-picker[data-queue-type='...'] returned null even though the element existed and was initialized. Switched to getElementById with a queueType→inputId map: cover → couverture note_intention → note_intention tfe → tfe-files-input annexe → annexe-files-input getElementById is both faster and immune to FilePond's DOM wrapping. --- TODO.md | 16 +--------- .../assets/js/app/file-upload-filepond.js | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/TODO.md b/TODO.md index 0b84a47..c7aab48 100644 --- a/TODO.md +++ b/TODO.md @@ -1,17 +1,3 @@ # TODO -- [x] Fix CSP: add `frame-src` to allow iframes from `videos.erg.be` and `depnum.happyngreen.fr` -- [x] Website iframe overlay: remove blur, move button to bottom-right, replace text with SVG icon + tooltip -- [x] Fix "Copier" button in logs section scrolling out of view on horizontal scroll -- [x] Remove TOC temporary debug error_log calls -- [x] Fix PeerTube upload failure: PHP /tmp tmpfs too small for large video files -- [x] Fix keyword word-breaking in repertoire.php: widen kw grid column, add white-space: nowrap -- [x] Fix licence.php TOC: restore `open` attribute on `
` (lost in vrxsstns, never restored by uuomvtvm fix) -- [x] Fix hasFilePondQueueData() missing peertube: prefix check → new PeerTube uploads silently lost on edit -- [x] Fix handleWebsiteUrl() in ThesisEditController unconditionally deleting website rows on every edit -- [x] Fix FilePond server.remove potentially triggering during HTMX fragment teardown -- [x] Add restore-from-corbeille functionality in cleanup page -- [x] Fix cleanup stats: use sidecar JSON for restorability classification (not DB row existence) -- [x] Remove destructive HTMX fragment refresh from relink flow (close modal only, pond.addFile in-place) -- [x] Merge corbeille lists into single table with status column + bulk restore button -- [x] Fix relinked file not appearing in FilePond UI: use addFiles([{type:'local'}]) instead of addFile(type:'limbo') +- [x] Fix relinked file not appearing in FilePond UI: switch to ID-based input lookup diff --git a/app/public/assets/js/app/file-upload-filepond.js b/app/public/assets/js/app/file-upload-filepond.js index b7e89de..df751ab 100644 --- a/app/public/assets/js/app/file-upload-filepond.js +++ b/app/public/assets/js/app/file-upload-filepond.js @@ -892,18 +892,21 @@ } console.log(`[relink] success | new_id=${data.id}`); - // Add the new file to the FilePond pool, then close the modal. - // If the DOM was replaced (e.g. live-reload), refresh the - // form fragment via HTMX so the server re-renders the pools - // with the newly-linked file included. - var input = document.querySelector( - `.tfe-file-picker[data-queue-type="${queueType}"]`, - ); + // Look up the FilePond pool by the known input ID for this queue type. + // querySelector on data-queue-type is unreliable after FilePond + // wraps the original input element. + var inputIdMap = { + cover: "couverture", + note_intention: "note_intention", + tfe: "tfe-files-input", + annexe: "annexe-files-input", + }; + var inputId = inputIdMap[queueType] || null; + var input = inputId ? document.getElementById(inputId) : null; console.log( - "[relink] looking for input | selector=" + - `.tfe-file-picker[data-queue-type="${queueType}"]` + - " | found=" + - !!input, + "[relink] looking for input | queueType=" + queueType + + " | inputId=" + inputId + + " | found=" + !!input, ); var closeModal = () => { var modal = document.getElementById("relink-modal"); @@ -1013,8 +1016,9 @@ } console.log(`[pt-relink] success | new_id=${data.id}`); - var input = document.querySelector( - '.tfe-file-picker[data-queue-type="tfe"]', + var input = document.getElementById("tfe-files-input"); + console.log( + "[pt-relink] looking for input | inputId=tfe-files-input | found=" + !!input, ); var closeModal = () => { var modal = document.getElementById("peertube-relink-modal");