From 4f1408cdcfb130259c9f04ec5acef341c4c2ed97 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Tue, 10 Feb 2026 13:10:32 +0800 Subject: [PATCH] fix(diff): reprocess htmx content after loading more files (#36568) (#36577) --- web_src/js/features/repo-diff.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/repo-diff.ts b/web_src/js/features/repo-diff.ts index ab08e6f03c..e41a61d05e 100644 --- a/web_src/js/features/repo-diff.ts +++ b/web_src/js/features/repo-diff.ts @@ -170,7 +170,9 @@ async function loadMoreFiles(btn: Element): Promise { const respFileBoxes = respDoc.querySelector('#diff-file-boxes'); // the response is a full HTML page, we need to extract the relevant contents: // * append the newly loaded file list items to the existing list - document.querySelector('#diff-incomplete').replaceWith(...Array.from(respFileBoxes.children)); + const respFileBoxesChildren = Array.from(respFileBoxes.children); // "children:HTMLCollection" will be empty after replaceWith + document.querySelector('#diff-incomplete').replaceWith(...respFileBoxesChildren); + for (const el of respFileBoxesChildren) window.htmx.process(el); onShowMoreFiles(); return true; } catch (error) { @@ -200,7 +202,7 @@ function initRepoDiffShowMore() { const resp = await response.text(); const respDoc = parseDom(resp, 'text/html'); const respFileBody = respDoc.querySelector('#diff-file-boxes .diff-file-body .file-body'); - const respFileBodyChildren = Array.from(respFileBody.children); // respFileBody.children will be empty after replaceWith + const respFileBodyChildren = Array.from(respFileBody.children); // "children:HTMLCollection" will be empty after replaceWith el.parentElement.replaceWith(...respFileBodyChildren); for (const el of respFileBodyChildren) window.htmx.process(el); // FIXME: calling onShowMoreFiles is not quite right here.