From d152af316c1186718d4f407c4ea6d2d3852d7fea Mon Sep 17 00:00:00 2001 From: Stefan Zwischenbrugger Date: Wed, 1 Apr 2026 15:31:57 +0200 Subject: [PATCH] Fix iPhone-Fokus nach Hinzufuegen. Setzt den Fokus auf iOS robuster ueber mehrere Trigger und Fallback ohne preventScroll, damit das Feld Neuer Eintrag nach Redirect wieder aktiv ist. Made-with: Cursor --- resources/views/shopping-list/index.blade.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/views/shopping-list/index.blade.php b/resources/views/shopping-list/index.blade.php index f88ea15..54fb3c2 100644 --- a/resources/views/shopping-list/index.blade.php +++ b/resources/views/shopping-list/index.blade.php @@ -374,8 +374,25 @@ if (!input) { return; } - input.focus({ preventScroll: true }); - input.select(); + const applyFocus = () => { + try { + input.focus({ preventScroll: true }); + } catch (_e) { + input.focus(); + } + try { + input.select(); + } catch (_e) { + // no-op + } + }; + + // iOS Safari ist bei Fokus nach Redirect empfindlich; daher mehrfach anstossen. + applyFocus(); + requestAnimationFrame(applyFocus); + setTimeout(applyFocus, 120); + setTimeout(applyFocus, 420); + window.addEventListener('pageshow', applyFocus, { once: true }); }); document.addEventListener('click', async (event) => {