Skip to content

Commit 4f1408c

Browse files
authored
fix(diff): reprocess htmx content after loading more files (#36568) (#36577)
1 parent 5973437 commit 4f1408c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

web_src/js/features/repo-diff.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ async function loadMoreFiles(btn: Element): Promise<boolean> {
170170
const respFileBoxes = respDoc.querySelector('#diff-file-boxes');
171171
// the response is a full HTML page, we need to extract the relevant contents:
172172
// * append the newly loaded file list items to the existing list
173-
document.querySelector('#diff-incomplete').replaceWith(...Array.from(respFileBoxes.children));
173+
const respFileBoxesChildren = Array.from(respFileBoxes.children); // "children:HTMLCollection" will be empty after replaceWith
174+
document.querySelector('#diff-incomplete').replaceWith(...respFileBoxesChildren);
175+
for (const el of respFileBoxesChildren) window.htmx.process(el);
174176
onShowMoreFiles();
175177
return true;
176178
} catch (error) {
@@ -200,7 +202,7 @@ function initRepoDiffShowMore() {
200202
const resp = await response.text();
201203
const respDoc = parseDom(resp, 'text/html');
202204
const respFileBody = respDoc.querySelector('#diff-file-boxes .diff-file-body .file-body');
203-
const respFileBodyChildren = Array.from(respFileBody.children); // respFileBody.children will be empty after replaceWith
205+
const respFileBodyChildren = Array.from(respFileBody.children); // "children:HTMLCollection" will be empty after replaceWith
204206
el.parentElement.replaceWith(...respFileBodyChildren);
205207
for (const el of respFileBodyChildren) window.htmx.process(el);
206208
// FIXME: calling onShowMoreFiles is not quite right here.

0 commit comments

Comments
 (0)