commit 8447cc2a3d1725364327ef9331628f7c59dd3968
parent bdcd9f94c2c1e3c0c8649255029c53c3b9a011de
Author: Florian Dold <dold@taler.net>
Date: Fri, 13 Nov 2026 01:06:16 +0100
merchant web UI: send wizard focus changes through requestFocus
Keep the existing step, validation and review-edit targets. Request
focus after revealing the requested control.
Assisted-by: LLM
Diffstat:
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/packages/taler-merchant-webui/src/screens/CreateSubscriptionScreen.tsx b/packages/taler-merchant-webui/src/screens/CreateSubscriptionScreen.tsx
@@ -14,6 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { useFocusScope } from "@gnu-taler/web-util/browser";
import type { VNode } from "preact";
import { session } from "../stores/session.js";
import { minimumSpendLabel, validityPeriodLabel } from "./token-setup/copy.js";
@@ -571,6 +572,10 @@ function CreateSubscriptionForm({
pendingFocus.current = problem.field;
setErrorMsg(problem.message, problem.field);
};
+ const { requestFocus } = useFocusScope({
+ root: () => formRef.current,
+ initialFocus: () => null,
+ });
const lastFocusedStep = useRef(step);
useLayoutEffect(() => {
if (!wizard) return;
@@ -585,16 +590,18 @@ function CreateSubscriptionForm({
root?.querySelector<HTMLElement>(`[data-field="${field}"]`))
: undefined) ?? root?.querySelector<HTMLElement>("#token-step-heading");
if (target) {
- (target.matches("input, select, textarea, button")
- ? target
- : (target.querySelector<HTMLElement>(
- "input, select, textarea, button",
- ) ?? target)
- ).focus({ preventScroll: true });
- if (field) target.scrollIntoView?.({ block: "nearest" });
+ requestFocus(
+ () =>
+ target.matches("input, select, textarea, button")
+ ? target
+ : (target.querySelector<HTMLElement>(
+ "input, select, textarea, button",
+ ) ?? target),
+ { scroll: !!field },
+ );
pendingFocus.current = null;
}
- }, [step, feedbackId, wizard]);
+ }, [step, feedbackId, wizard, requestFocus]);
const navigateStep = (next: TokenSetupStep) => {
if (submitting.current) return;
if (steps.indexOf(next) > steps.indexOf(step)) {