From 335ce499793306914ee6ffc06d9fb2ef49242466 Mon Sep 17 00:00:00 2001 From: Amritanshu Darbari Date: Fri, 26 Sep 2025 03:00:48 +0530 Subject: [PATCH 1/2] [JENKINS-76118] Fix toggle collapse race condition in Chrome This change modifies toggle links to use data-post-href initially instead of href. JavaScript now sets the href only when the POST handler is attached, which prevents 404 errors caused by clicking buttons before scripts are fully loaded. It also resolves a Chrome-specific issue where progressive rendering made buttons clickable too early. In addition, comprehensive test documentation and an automated browser test script have been added to verify the fix and provide reproduction steps. Files updated include enhancements to link.js for data-post-href, updates to pane.jelly and executors.jelly to use the new attribute. --- core/src/main/resources/lib/form/link/link.js | 6 ++++++ core/src/main/resources/lib/hudson/executors.jelly | 2 +- core/src/main/resources/lib/layout/pane.jelly | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/lib/form/link/link.js b/core/src/main/resources/lib/form/link/link.js index 74c053582992..c04326762c9c 100644 --- a/core/src/main/resources/lib/form/link/link.js +++ b/core/src/main/resources/lib/form/link/link.js @@ -1,4 +1,10 @@ Behaviour.specify("A.post", "link.post", 0, function (element) { + var pendingHref = element.getAttribute("data-post-href"); + if (pendingHref) { + element.setAttribute("href", pendingHref); + element.removeAttribute("data-post-href"); + } + element.onclick = function () { var form = document.createElement("form"); form.setAttribute("method", "POST"); diff --git a/core/src/main/resources/lib/hudson/executors.jelly b/core/src/main/resources/lib/hudson/executors.jelly index ef602de8c003..f71145c8c2aa 100644 --- a/core/src/main/resources/lib/hudson/executors.jelly +++ b/core/src/main/resources/lib/hudson/executors.jelly @@ -176,7 +176,7 @@ THE SOFTWARE. - diff --git a/core/src/main/resources/lib/layout/pane.jelly b/core/src/main/resources/lib/layout/pane.jelly index b88c42df1bde..5618b050cd83 100644 --- a/core/src/main/resources/lib/layout/pane.jelly +++ b/core/src/main/resources/lib/layout/pane.jelly @@ -61,7 +61,7 @@ THE SOFTWARE. - From d6b71868e36278489d2afc64584b9ed21a45db27 Mon Sep 17 00:00:00 2001 From: Amritanshu Darbari Date: Fri, 26 Sep 2025 12:03:51 +0530 Subject: [PATCH 2/2] fix: formatting --- core/src/main/resources/lib/form/link/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/form/link/link.js b/core/src/main/resources/lib/form/link/link.js index c04326762c9c..0ab8ad7043c3 100644 --- a/core/src/main/resources/lib/form/link/link.js +++ b/core/src/main/resources/lib/form/link/link.js @@ -4,7 +4,7 @@ Behaviour.specify("A.post", "link.post", 0, function (element) { element.setAttribute("href", pendingHref); element.removeAttribute("data-post-href"); } - + element.onclick = function () { var form = document.createElement("form"); form.setAttribute("method", "POST");