diff --git a/src/features/auth/login/login/PickLoginServer.tsx b/src/features/auth/login/login/PickLoginServer.tsx index 47ca34c177..977c52efe5 100644 --- a/src/features/auth/login/login/PickLoginServer.tsx +++ b/src/features/auth/login/login/PickLoginServer.tsx @@ -164,7 +164,7 @@ export default function PickLoginServer() { { diff --git a/src/features/auth/login/pickJoinServer/PickJoinServer.tsx b/src/features/auth/login/pickJoinServer/PickJoinServer.tsx index 2e45bcb287..0a16846f52 100644 --- a/src/features/auth/login/pickJoinServer/PickJoinServer.tsx +++ b/src/features/auth/login/pickJoinServer/PickJoinServer.tsx @@ -43,6 +43,7 @@ import Login from "#/features/auth/login/login/Login"; import AppHeader from "#/features/shared/AppHeader"; import { DynamicDismissableModalContext } from "#/features/shared/DynamicDismissableModal"; import { isIosTheme } from "#/helpers/device"; +import { blurOnEnter } from "#/helpers/dom"; import { isMinimumSupportedLemmyVersion } from "#/helpers/lemmy"; import { isValidHostname, stripProtocol } from "#/helpers/url"; import { defaultServersUntouched, getCustomServers } from "#/services/app"; @@ -349,13 +350,9 @@ export default function PickJoinServer() { setSearch(e.detail.value || "")} - onKeyDown={(e) => { - if (e.key !== "Enter") return; - - if (e.target instanceof HTMLElement) e.target.blur(); - }} + onKeyDown={blurOnEnter} inputMode="url" - enterkeyhint="go" + enterkeyhint="done" /> { setTag((tag) => { const newTag = { ...tag, text: e.detail.value ?? "" }; @@ -191,9 +202,9 @@ function UserTagModalContents({ { setTag((tag) => { diff --git a/src/helpers/dom.ts b/src/helpers/dom.ts index 217e087347..cd488f645a 100644 --- a/src/helpers/dom.ts +++ b/src/helpers/dom.ts @@ -1,3 +1,5 @@ +import { KeyboardEvent } from "react"; + import { ua } from "./device"; export const useScrollIntoViewWorkaround = ua.getEngine().name === "WebKit"; @@ -138,3 +140,9 @@ export function getSelectionHtml(selection: Selection): string { return html; } + +export function blurOnEnter(e: KeyboardEvent) { + if (e.key !== "Enter") return; + + if (e.target instanceof HTMLElement) e.target.blur(); +}