refactor: enhanced Join Private Lobby form (#3284)

## Description:
This pull request enhances the `JoinLobbyModal` component by using the
`<form>` component and the `@submit` event. It allows the user to use
the enter (return) key to submit instead of grabbing its mouse to click
on "Join Lobby".
It also introduces a new `submit` argument to the `Button` component.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:
@nolhan__

PS: The tests from `tests/InputHandler.test.ts` are failing on both
`main` and my branch. EDIT: They no longer fail through the workflow so
I guess I didn't have the correct environment
This commit is contained in:
Nolhan
2026-02-23 19:02:24 +00:00
committed by GitHub
parent 4788316504
commit e5ce278cb1
2 changed files with 6 additions and 3 deletions
+4 -3
View File
@@ -221,7 +221,7 @@ export class JoinLobbyModal extends BaseModal {
onBack: () => this.closeAndLeave(),
ariaLabel: translateText("common.close"),
})}
<div class="flex-1 overflow-y-auto custom-scrollbar p-6 space-y-4 mr-1">
<form @submit=${this.joinLobbyFromInput} class="flex-1 overflow-y-auto custom-scrollbar p-6 space-y-4 mr-1">
<div class="flex flex-col gap-3">
<div class="flex gap-2">
<input
@@ -255,7 +255,7 @@ export class JoinLobbyModal extends BaseModal {
<o-button
title=${translateText("private_lobby.join_lobby")}
block
@click=${this.joinLobbyFromInput}
submit
></o-button>
</div>
</div>
@@ -673,7 +673,8 @@ export class JoinLobbyModal extends BaseModal {
}
}
private async joinLobbyFromInput(): Promise<void> {
private async joinLobbyFromInput(e: SubmitEvent): Promise<void> {
e.preventDefault();
const lobbyId = this.normalizeLobbyId(this.lobbyIdInput.value);
if (!lobbyId) {
this.showMessage(translateText("private_lobby.not_found"), "red");