fix: remove the pull merge box from UI when the refreshed page doesn't contain it (#38742) (#38744)

backport #38742
This commit is contained in:
wxiaoguang
2026-08-02 22:55:17 +08:00
committed by GitHub
parent a8e80ebc23
commit 7fb9602961
+7 -1
View File
@@ -80,7 +80,13 @@ export function initRepoPullMergeBox(el: HTMLElement) {
return;
}
document.removeEventListener('visibilitychange', onVisibilityChange);
const newElem = createElementFromHTML(await resp.text());
const respText = (await resp.text()).trim();
if (!respText) {
el.remove(); // merge box might not exist if the PR has changed (e.g.: merged and the head branch has been deleted)
return;
}
const newElem = createElementFromHTML(respText);
el.replaceWith(newElem);
};