Skip to content

Commit a2f29e5

Browse files
authored
Merge pull request #44888 from tienifr/fix/32683
fix: safari password autofill does not disappear
2 parents abbe80d + e70ae1e commit a2f29e5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import {isSafari} from '@libs/Browser';
3+
import type ChildrenProps from '@src/types/utils/ChildrenProps';
4+
5+
type SafariFormWrapperProps = ChildrenProps;
6+
7+
/**
8+
* If we used any <input> without <form> wrapper, Safari 11+ would show the auto-fill suggestion popup.
9+
*/
10+
function SafariFormWrapper({children}: SafariFormWrapperProps) {
11+
if (isSafari()) {
12+
return <form>{children}</form>;
13+
}
14+
15+
return children;
16+
}
17+
18+
export default SafariFormWrapper;

src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {View} from 'react-native';
44
import type {OnyxEntry} from 'react-native-onyx';
55
import {withOnyx} from 'react-native-onyx';
66
import Button from '@components/Button';
7+
import SafariFormWrapper from '@components/Form/SafariFormWrapper';
78
import FormHelpMessage from '@components/FormHelpMessage';
89
import type {MagicCodeInputHandle} from '@components/MagicCodeInput';
910
import MagicCodeInput from '@components/MagicCodeInput';
@@ -291,7 +292,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
291292
}, [account, credentials, twoFactorAuthCode, validateCode, isUsingRecoveryCode, recoveryCode]);
292293

293294
return (
294-
<>
295+
<SafariFormWrapper>
295296
{/* At this point, if we know the account requires 2FA we already successfully authenticated */}
296297
{account?.requiresTwoFactorAuth ? (
297298
<View style={[styles.mv3]}>
@@ -402,7 +403,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
402403
<View style={[styles.mt5, styles.signInPageWelcomeTextContainer]}>
403404
<Terms />
404405
</View>
405-
</>
406+
</SafariFormWrapper>
406407
);
407408
}
408409

0 commit comments

Comments
 (0)