From 86beb8a5dd6ce227973a2ff5aefb417c8486f66b Mon Sep 17 00:00:00 2001 From: oimwiodev Date: Sun, 31 May 2026 21:09:22 +0100 Subject: [PATCH] Keep tablet keyboard open between wizard fields --- src/components/seller-wizard/SellerWizard.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/seller-wizard/SellerWizard.tsx b/src/components/seller-wizard/SellerWizard.tsx index e2c437c..54fe91f 100644 --- a/src/components/seller-wizard/SellerWizard.tsx +++ b/src/components/seller-wizard/SellerWizard.tsx @@ -139,6 +139,7 @@ export function SellerWizard() { codePostal: '', }) const touchStart = useRef<{ x: number; y: number; time: number } | null>(null) + const activeClientInputRef = useRef(null) useEffect(() => { loadClients() @@ -176,6 +177,11 @@ export function SellerWizard() { } }, [createClientOpen]) + useEffect(() => { + if (!createClientOpen) return + focusActiveClientInput() + }, [clientFieldIndex, createClientOpen]) + const filteredClients = useMemo(() => { const query = clientSearch.toLowerCase().trim() if (!query) return clients.slice(0, 20) @@ -260,11 +266,20 @@ export function SellerWizard() { setError('') if (clientFieldIndex < clientFields.length - 1) { setClientFieldIndex((index) => index + 1) + focusActiveClientInput() } else { createClient() } } + function focusActiveClientInput() { + window.requestAnimationFrame(() => { + window.requestAnimationFrame(() => { + activeClientInputRef.current?.focus({ preventScroll: true }) + }) + }) + } + async function createClient() { setLoading(true) setError('') @@ -425,6 +440,7 @@ export function SellerWizard() { nextClientField() } else { setClientFieldIndex((index) => Math.max(0, index - 1)) + focusActiveClientInput() } } @@ -553,6 +569,7 @@ export function SellerWizard() {
setNewClient({ ...newClient, [currentField.key]: event.target.value }) @@ -572,6 +589,7 @@ export function SellerWizard() { />