From 7134f6165d8cfa0d22c522ae4676071b0f2d1d5b Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 17 Nov 2025 14:17:59 +0200 Subject: [PATCH] fix password autofill on iOS --- src/screens/Login/LoginForm.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index b6a528e42b..0d8c1b9668 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -18,10 +18,11 @@ import {isNetworkError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors' import {createFullHandle} from '#/lib/strings/handles' import {logger} from '#/logger' +import {isIOS} from '#/platform/detection' import {useSetHasCheckedForStarterPack} from '#/state/preferences/used-starter-packs' import {useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a, ios, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {FormError} from '#/components/forms/FormError' import {HostingProvider} from '#/components/forms/HostingProvider' @@ -69,7 +70,9 @@ export const LoginForm = ({ const identifierValueRef = useRef(initialHandle || '') const passwordValueRef = useRef('') const authFactorTokenValueRef = useRef('') + const identifierRef = useRef(null) const passwordRef = useRef(null) + const hasFocusedOnce = useRef(false) const {_} = useLingui() const {login} = useSessionApi() const requestNotificationsPermission = useRequestNotificationsPermission() @@ -198,9 +201,10 @@ export const LoginForm = ({ { + if (hasFocusedOnce.current) return + hasFocusedOnce.current = true + // kinda dumb, but if we use `autoFocus` to focus + // the username input, it happens before the password + // input gets rendered. this breaks the password autofill + // on iOS (it only does the username part). delaying + // it until both inputs are rendered fixes the autofill -sfn + identifierRef.current?.focus() + })} />