From d15cfa363a154fa6dcbe39c5277cf335a453051b Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 13 Jul 2026 14:38:41 +0800 Subject: [PATCH] chore: don't auto refresh the merge box when user has interacted with it (#38435) Otherwise, the user just isn't able to use "auto merge" form --- web_src/js/features/repo-issue-pull.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/repo-issue-pull.ts b/web_src/js/features/repo-issue-pull.ts index cecc39ee30b..3fcaa604467 100644 --- a/web_src/js/features/repo-issue-pull.ts +++ b/web_src/js/features/repo-issue-pull.ts @@ -36,10 +36,19 @@ async function initRepoPullRequestMergeForm(box: HTMLElement) { } function initRepoPullMergeBoxRefresh(el: Element) { + // The merge box has complex buttons & form, if the user has interacted with any element, don't refresh. + // Otherwise, the user won't be able to merge or schedule a merge (auto-merge) when the PR status is not ready. + let interacted = false; + const interactionEvents = ['focusin', 'mousedown', 'click', 'keydown', 'input']; + for (const event of interactionEvents) { + el.addEventListener(event, () => { interacted = true }, {capture: true}); + } + activePageTimerRefresh({ once: true, // on successful refresh, the data-global-init will re-initialize the element - interval: () => Number(el.getAttribute('data-pull-merge-box-reloading-interval')), + interval: () => interacted ? 0 : Number(el.getAttribute('data-pull-merge-box-reloading-interval')), async callback() { + if (interacted) return; const pullLink = el.getAttribute('data-pull-link')!; const resp = await GET(`${pullLink}/merge_box`); if (!resp.ok) return;