From b969123b7fac51c88daab5cb64e5b2f4abd53288 Mon Sep 17 00:00:00 2001 From: bircni Date: Mon, 13 Jul 2026 11:54:47 +0200 Subject: [PATCH] chore: don't auto refresh the merge box when user has interacted with it (#38436) Backport #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 7a72d267fce..853d869e3ea 100644 --- a/web_src/js/features/repo-issue-pull.ts +++ b/web_src/js/features/repo-issue-pull.ts @@ -46,6 +46,14 @@ export function initRepoPullMergeBox(el: HTMLElement) { const pullLink = el.getAttribute('data-pull-link'); let timerId: number | null; + // 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}); + } + let reloadMergeBox: () => Promise; const stopReloading = () => { if (!timerId) return; @@ -53,7 +61,7 @@ export function initRepoPullMergeBox(el: HTMLElement) { timerId = null; }; const startReloading = () => { - if (timerId) return; + if (timerId || interacted) return; setTimeout(reloadMergeBox, reloadingInterval); }; const onVisibilityChange = () => { @@ -64,6 +72,7 @@ export function initRepoPullMergeBox(el: HTMLElement) { } }; reloadMergeBox = async () => { + if (interacted) return; const resp = await GET(`${pullLink}/merge_box`); stopReloading(); if (!resp.ok) {