Skip to content

Commit

Permalink
feat: Complete login on Enter key press in password input
Browse files Browse the repository at this point in the history
  • Loading branch information
Ushie committed Dec 15, 2024
1 parent 02f7c27 commit 5d371c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/layout/Navbar/NavHost.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@
<form on:submit|preventDefault={handle_login} bind:this={loginForm}>
<div>
<Input placeholder="Username" required />
<Input placeholder="Password" type="password" required />
<Input
placeholder="Password"
type="password"
onkeydown={(event) => event.key === 'Enter' && loginForm.requestSubmit()}
required
/>
</div>
</form>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export let onenter: () => void = () => {};
export let onexit: () => void = () => {};
export let oninput: () => void = () => {};
export let onkeydown: (event: KeyboardEvent) => void = (event) => {};
const set_type = (node: HTMLInputElement) => {
node.type = type;
Expand All @@ -22,6 +23,7 @@
on:focus={onenter}
on:blur={onexit}
on:input={oninput}
on:keydown={onkeydown}
bind:value
/>
<label for={placeholder.toLowerCase()}>{placeholder}</label>
Expand Down

0 comments on commit 5d371c5

Please sign in to comment.