Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safari password autofill does not disappear #44888

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some comments explaining why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment!

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
Loading