From 7fb9602961e37f8c58397fc0a26817de9d5ee36f Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 2 Aug 2026 22:55:17 +0800 Subject: [PATCH] fix: remove the pull merge box from UI when the refreshed page doesn't contain it (#38742) (#38744) backport #38742 --- web_src/js/features/repo-issue-pull.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/repo-issue-pull.ts b/web_src/js/features/repo-issue-pull.ts index 853d869e3e..110d5a9051 100644 --- a/web_src/js/features/repo-issue-pull.ts +++ b/web_src/js/features/repo-issue-pull.ts @@ -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); };