Repository navigation
Submit the GitHub username with Enter - #122
Conversation
The lobby username field required moving focus to Use GitHub before submitting. Route Enter through the same guarded button action, while leaving composition Enter available for text input.
| nodes.githubLogin.addEventListener("keydown", (event) => { | ||
| if (event.key !== "Enter" || event.isComposing) return; | ||
| event.preventDefault(); | ||
| nodes.loginLink.click(); |
There was a problem hiding this comment.
The handler this reaches clears disabled after recordGitHubLogin(true) returns, and that return happens once window.location.reload() is queued but before the new document commits, so the button is armed again for the whole unload. A held Enter repeats at the key rate and lands another /api/login in that window, which the server may rate limit. The pending test presses Enter only while the request is in flight, never after it resolves, so it does not cover this. Leave disabled set on success and clear it only on the failure return.
There was a problem hiding this comment.
Successful header sign-in now updates the account and history without reloading. Login and Start stay blocked through the refresh, and queued events targeting the hidden login button cannot send another POST. An explicit HTTP rejection permits retry; a timeout or connection failure with an unknown POST outcome instead offers a GET-only account check before another login is allowed.
| nodes.githubLogin.addEventListener("keydown", (event) => { | ||
| if (event.key !== "Enter" || event.isComposing) return; | ||
| event.preventDefault(); | ||
| nodes.loginLink.click(); |
There was a problem hiding this comment.
Reusing #login-link also inherits its recordGitHubLogin(true), so Enter reloads the lobby. A candidate who picked a problem, set a duration, moved the difficulty filters, or loaded a job description and resume loses all of it to one keypress in the header field, where before it took a deliberate press of Use GitHub. The description sells the reuse as preserving the disabled state and does not mention that it also preserves the reload. The start path records a login without reloading, via recordGitHubLogin(false); as a follow-up, doing the same here and refreshing the account row in place would keep the candidate's work on screen.
There was a problem hiding this comment.
Implemented the in-place refresh. Enter and button tests preserve the manually selected problem, difficulty, duration, profile, round plan, loaded JD/resume selections and document consent, then verify what reaches Start. Account-check failure offers a GET-only retry. The server duration cap still applies, and a changed practice weakness withdraws consent to share the previous text.
Header sign-in could race Start and discard the candidate's interview setup. Keep that setup on screen while account changes settle, and make an uncertain login result recoverable without silently recording a second session. Bound account reads and login requests to ten seconds and cover the transition, IME confirmation and preserved choices with browser tests.
|
Thank @Suzu1Dev for contributing! |
The lobby username field required moving focus to Use GitHub before submitting. Let Enter invoke the existing button action while leaving composition Enter to the input method. Reusing the button preserves its disabled state while a request is pending.
Testing:
./scripts/test.shpasses oncb4e88a, including all 653 browser tests with 0 skipped. All optional local tool checks ran. The added Chromium tests cover ordinary Enter, composition followed by a committed username, and repeated Enter during a pending request. Removing the handler or the composition guard makes the corresponding regression test fail.Summary by cubic
Allows pressing Enter in the GitHub username field to submit the login, reusing the guarded button action so the disabled state still applies while a request is pending; composition Enter (IME) stays with the input method.
This also keeps the lobby's interview setup intact while account changes settle. Login, Start, history refreshes, and report deletion now share one state lock, an uncertain login result can be retried without recording a duplicate session, and header sign-in no longer races Start into a lost interview selection. Account reads and login requests are bounded to ten seconds and fall back without leaving controls stuck.
Written for commit 836ae24. Summary will update on new commits.