commit 460b2808ea3a4cd62a07cd9e9cb4ddced399872c parent 4bf1b24fba1731d01ba25153beef6d53e0bbd103 Author: Florian Dold <dold@taler.net> Date: Fri, 13 Nov 2026 01:06:16 +0100 merchant web UI: focus merchant account and server setup forms Start account creation, password reset and server setup on the first field the user needs to fill. Issue: https://bugs.taler.net/n/12007 Issue: https://bugs.taler.net/n/12008 Issue: https://bugs.taler.net/n/12009 Issue: https://bugs.taler.net/n/12010 Assisted-by: LLM Diffstat:
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/packages/taler-merchant-webui/src/screens/AdminAccountCredentialsScreen.tsx b/packages/taler-merchant-webui/src/screens/AdminAccountCredentialsScreen.tsx @@ -7,9 +7,10 @@ Foundation; either version 3, or (at your option) any later version. */ +import { useFocusScope, firstEditableField } from "@gnu-taler/web-util/browser"; import { FormActionFooter, useFormFeedback } from "../ui/FormActionFooter.js"; import type { VNode } from "preact"; -import { useState } from "preact/hooks"; +import { useRef, useState } from "preact/hooks"; import { Header } from "../ui/Header.js"; import { Button } from "../ui/Button.js"; import { PasswordInput } from "../ui/PasswordInput.js"; @@ -37,6 +38,12 @@ export function AdminAccountCredentialsScreen({ fieldError, } = useFormFeedback(); const [pending, setPending] = useState(false); + // The new password is all this page asks for. + const form = useRef<HTMLFormElement>(null); + useFocusScope({ + root: () => form.current, + initialFocus: () => firstEditableField(form.current, true), + }); const submit = async (event: Event) => { event.preventDefault(); @@ -79,6 +86,7 @@ export function AdminAccountCredentialsScreen({ <div class="rounded-lg border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950">{t`The account’s existing password will stop working. Existing login tokens remain governed by the backend’s token policy.`}</div> <form + ref={form} onSubmit={(event) => void submit(event)} class="space-y-5 rounded-xl border border-gray-200 bg-white p-5" > diff --git a/packages/taler-merchant-webui/src/screens/AdminAccountFormScreen.tsx b/packages/taler-merchant-webui/src/screens/AdminAccountFormScreen.tsx @@ -7,9 +7,10 @@ Foundation; either version 3, or (at your option) any later version. */ +import { useFocusScope } from "@gnu-taler/web-util/browser"; import { FormActionFooter, useFormFeedback } from "../ui/FormActionFooter.js"; import type { VNode } from "preact"; -import { useState } from "preact/hooks"; +import { useRef, useState } from "preact/hooks"; import { isValidMerchantInstanceId, normalizeMerchantInstanceId, @@ -96,6 +97,13 @@ function AdminAccountFormInner({ const { t } = useTranslation(); const [value, setValue] = useState<AdminAccountFormValue>(initial); const [confirmPassword, setConfirmPassword] = useState(""); + // A new account starts with its identifier. When editing, the identifier is + // fixed and no field in particular comes first. + const accountIdInput = useRef<HTMLInputElement>(null); + useFocusScope({ + active: mode === "create", + initialFocus: () => accountIdInput.current, + }); const [showAdvancedRequested, setShowAdvanced] = useState(mode === "edit"); const [ignoreInvalidLogo, setIgnoreInvalidLogo] = useState(false); const [customTiming, setCustomTiming] = useState( @@ -256,6 +264,7 @@ function AdminAccountFormInner({ {t`Account ID`} * </label> <input + ref={accountIdInput} {...fieldProps("managed-account-id")} id="managed-account-id" value={value.id} diff --git a/packages/taler-merchant-webui/src/screens/BootstrapInstanceScreen.tsx b/packages/taler-merchant-webui/src/screens/BootstrapInstanceScreen.tsx @@ -7,6 +7,7 @@ Foundation; either version 3, or (at your option) any later version. */ +import { useFocusScope } from "@gnu-taler/web-util/browser"; import { ActionFooter } from "../ui/FormActionFooter.js"; import type { VNode } from "preact"; import { useRef, useState } from "preact/hooks"; @@ -41,6 +42,10 @@ export function BootstrapInstanceScreen({ const [error, setError] = useState<unknown>(); const [pending, setPending] = useState(false); const submissionLock = useRef(false); + // The account identifier is fixed, so the business name is the first thing + // this page asks for. + const businessNameInput = useRef<HTMLInputElement>(null); + useFocusScope({ initialFocus: () => businessNameInput.current }); const submit = async (event: Event) => { event.preventDefault(); @@ -134,6 +139,7 @@ export function BootstrapInstanceScreen({ {t`Business name`} </label> <input + ref={businessNameInput} id="bootstrap-business-name" value={businessName} onInput={(event) => setBusinessName(event.currentTarget.value)} diff --git a/packages/taler-merchant-webui/src/screens/ChangeServerUrlScreen.tsx b/packages/taler-merchant-webui/src/screens/ChangeServerUrlScreen.tsx @@ -14,9 +14,10 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ +import { useFocusScope } from "@gnu-taler/web-util/browser"; import { ActionFooter } from "../ui/FormActionFooter.js"; import type { VNode } from "preact"; -import { useState } from "preact/hooks"; +import { useRef, useState } from "preact/hooks"; import { TalerLogo } from "../ui/TalerLogo.js"; import { CopyErrorButton } from "../ui/CopyErrorButton.js"; import { currentBackendUrl, setCustomBackendUrl } from "../stores/session.js"; @@ -73,6 +74,9 @@ export function ChangeServerUrlScreen({ const [url, setUrl] = useState<string>(initialUrl || currentBackendUrl.value); const [errorMsg, setErrorMsg] = useState<string>(""); const [isVerifying, setIsVerifying] = useState<boolean>(false); + // The address is what this page is for. + const urlInput = useRef<HTMLInputElement>(null); + useFocusScope({ initialFocus: () => urlInput.current }); const handleSubmit = async (e: Event) => { e.preventDefault(); @@ -193,6 +197,7 @@ export function ChangeServerUrlScreen({ {t`Server address`} <span class="text-red-500">*</span> </label> <input + ref={urlInput} id="server-url-input" type="url" value={url}