Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Modifier-click detection, stale keyboard state, and alternate submit-button handling contain functional defects.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates login themes to disable submit buttons only for same-tab submissions, addressing #52056.
Changes:
- Adds a shared submit-handling module.
- Migrates base, Keycloak v2, logout, and organization forms from inline handlers.
File summaries
| File | Description |
|---|---|
themes/src/main/resources/theme/keycloak.v2/login/template.ftl |
Loads the shared module. |
themes/src/main/resources/theme/keycloak.v2/login/login.ftl |
Migrates login form handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-username.ftl |
Migrates username form handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-update-password.ftl |
Migrates password-update handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-recovery-authn-code-input.ftl |
Migrates recovery-code handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-password.ftl |
Migrates password form handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-passkeys-conditional-authenticate.ftl |
Migrates conditional passkey form handling. |
themes/src/main/resources/theme/keycloak.v2/login/login-otp.ftl |
Migrates OTP form handling. |
themes/src/main/resources/theme/base/login/template.ftl |
Loads the shared module. |
themes/src/main/resources/theme/base/login/resources/js/disableSubmitOnSameTab.js |
Implements submission detection and disabling. |
themes/src/main/resources/theme/base/login/logout-confirm.ftl |
Migrates logout confirmation handling. |
themes/src/main/resources/theme/base/login/login.ftl |
Migrates login form handling. |
themes/src/main/resources/theme/base/login/login-username.ftl |
Migrates username form handling. |
themes/src/main/resources/theme/base/login/login-update-password.ftl |
Migrates password-update handling. |
themes/src/main/resources/theme/base/login/login-recovery-authn-code-input.ftl |
Migrates recovery-code handling. |
themes/src/main/resources/theme/base/login/login-password.ftl |
Migrates password form handling. |
themes/src/main/resources/theme/base/login/login-passkeys-conditional-authenticate.ftl |
Migrates conditional passkey form handling. |
themes/src/main/resources/theme/base/login/login-otp.ftl |
Migrates OTP form handling. |
testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/resources/theme/organization/login/login.ftl |
Migrates organization login handling. |
testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/resources/theme/organization/login/login-username.ftl |
Migrates organization username handling. |
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabledKeycloak CI - Java Distribution IT (windows-latest - temurin - 17) |
There was a problem hiding this comment.
🟡 Changes recommended
A canceled modified click can poison the next normal submission, and the behavior lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 2
- Review effort level: Balanced
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.
There was a problem hiding this comment.
🔵 Needs a closer look
Submitter target precedence is implemented incorrectly, and the browser-specific behavior lacks regression coverage.
Review details
Suppressed comments (2)
themes/src/main/resources/theme/base/login/resources/js/disableSubmitOnSameTab.js:14
- The form-level target is checked before the submitter override, but HTML gives
formtargeton the submitter precedence. A form targeting_blankwith a_selfsubmit button will therefore leave that button enabled even though the current tab is submitted.
function opensInNewTab(form, event) {
if (form.target && form.target !== "_self") {
return true;
}
const submitter = event.submitter;
if (submitter instanceof HTMLButtonElement || submitter instanceof HTMLInputElement) {
const formTarget = submitter.formTarget || submitter.getAttribute("formtarget");
themes/src/main/resources/theme/base/login/resources/js/disableSubmitOnSameTab.js:74
- This browser-event behavior has no automated regression coverage, despite the existing multi-tab login suite in
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/MultipleTabsLoginTest.java. Add coverage for normal submit disabling and modifier-key submit preserving the original tab's enabled button so browser-specific event-order regressions are caught.
form.addEventListener("submit", (event) => {
const newTabSubmit = modifierNewTabSubmit || opensInNewTab(form, event);
modifierNewTabSubmit = false;
if (newTabSubmit) {
- Files reviewed: 20/20 changed files
- Comments generated: 0 new
- Review effort level: Balanced
5fcc2c1 to
5348bdc
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The target check ignores the submitter’s formtarget override, leaving the button enabled and duplicate-submit protection inactive when a _blank form is submitted with formtarget="_self".
No open issues 🎉
9 resolved since last review
Two issues here: (1)namedItem(buttonName)can return aRadioNodeList(or another… ResettingmodifierNewTabSubmitviaqueueMicrotaskcan be timing-sensitive relative to the… ResettingmodifierNewTabSubmitviaqueueMicrotaskcan be timing-sensitive relative to the…event.targetis not guaranteed to be anElement(it can be a text node in some cases). Calling… A modified click that does not produce asubmitevent (for example, when activation is canceled)… Always preferringevent.submitterbreaks the app-initiated update-password cancel action:… This flag remains set when modifier+Enter does not submit the form—for example, on a focused…event.submitteris the submit control element, not the originating click event, so it never… This new browser-event behavior has no automated regression coverage, so modifier handling and…
Review effort: Balanced
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.client.FAPI1Test#testFAPIAdvancedLoginWithPrivateKeyJWTKeycloak CI - FIPS IT (strict) |
5348bdc to
a91c9db
Compare
Shift+Enter or modifier-click can submit the login form in a new tab while the original page stays open. The inline onsubmit handler disabled the submit button unconditionally, leaving the page stuck with a disabled Sign In button. Replace the inline handlers with a shared script that skips disabling when modifier keys are used or the form targets a new browsing context. Closes keycloak#52056 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Capture modifier keys from click/keydown events instead of the submitter element, clear stale keyboard modifier state when Enter does not submit, and always disable the button named by data-kc-disable-submit. Closes keycloak#52056 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Reset modifierNewTabSubmit in a microtask when a modified click on a submit control does not produce a submit event, matching the keydown path. Closes keycloak#52056 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Guard closest() when the click target is not an Element, defer modifier flag cleanup with setTimeout to avoid racing submit, verify the named control is disableable, and honor per-button formtarget overrides. Closes keycloak#52056 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
a91c9db to
6a1facf
Compare
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>


Summary
handlers with a shareddisableSubmitOnSameTab.jsscript that only disables the submit button for same-tab submissionsCloses #52056
Test plan