Skip to content

Commit

Permalink
Merge pull request #44888 from tienifr/fix/32683
Browse files Browse the repository at this point in the history
fix: safari password autofill does not disappear
  • Loading branch information
cristipaval authored Jul 11, 2024
2 parents abbe80d + e70ae1e commit a2f29e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/components/Form/SafariFormWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import {isSafari} from '@libs/Browser';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

type SafariFormWrapperProps = ChildrenProps;

/**
* If we used any <input> without <form> wrapper, Safari 11+ would show the auto-fill suggestion popup.
*/
function SafariFormWrapper({children}: SafariFormWrapperProps) {
if (isSafari()) {
return <form>{children}</form>;
}

return children;
}

export default SafariFormWrapper;
5 changes: 3 additions & 2 deletions src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import SafariFormWrapper from '@components/Form/SafariFormWrapper';
import FormHelpMessage from '@components/FormHelpMessage';
import type {MagicCodeInputHandle} from '@components/MagicCodeInput';
import MagicCodeInput from '@components/MagicCodeInput';
Expand Down Expand Up @@ -291,7 +292,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
}, [account, credentials, twoFactorAuthCode, validateCode, isUsingRecoveryCode, recoveryCode]);

return (
<>
<SafariFormWrapper>
{/* At this point, if we know the account requires 2FA we already successfully authenticated */}
{account?.requiresTwoFactorAuth ? (
<View style={[styles.mv3]}>
Expand Down Expand Up @@ -402,7 +403,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
<View style={[styles.mt5, styles.signInPageWelcomeTextContainer]}>
<Terms />
</View>
</>
</SafariFormWrapper>
);
}

Expand Down

0 comments on commit a2f29e5

Please sign in to comment.