Closed taylor-kn closed 2 years ago
I too recently have come across this error with AmplifySignIn and Amplify Signup. I used hideToast to hide the error message and added code to create my own error styling.
const [alertMessage, setAlertMessage] = useState('');
const handleToastErrors = ({ payload }) => {
if (payload.event === AUTH_STATE_CHANGE_EVENT) {
setAlertMessage('');
}
if (payload.event === TOAST_AUTH_ERROR_EVENT && payload.message) {
setAlertMessage(payload.message);
}
};
useEffect(() => {
Hub.listen(UI_AUTH_CHANNEL, handleToastErrors);
return () => Hub.remove(UI_AUTH_CHANNEL, handleToastErrors);
});
const renderSignIn = (
<>
{alertMessage && (<div className="customToast">{alertMessage}</div>)}
<AmplifyAuthenticator
usernameAlias="username"
headerText="Sign in or create an account"
hideToast
>
<AmplifySignUp
headerText="Create account"
slot="sign-up"
/>
<AmplifySignIn slot="sign-in" usernameAlias="username" />
<AmplifyConfirmSignUp
headerText="Please check your text messages for your confirmation code"
/>
</AmplifyAuthenticator>
</>
);`
@taylor-kn @nstilesm I'm actually having trouble reproducing this. I set up a new app for this and was able to sign up and, subsequently, sign in a user using Chrome on Android without issue. No errors popped up for me. I used the code sample you provided and tried with both the versions of amplify/ui-react that you are using, and the latest versions as well. Both were successful.
Can you share which version of Android you are using and what version of Chrome on Android you are using?
@eddiekeller the versions of Chrome that produced the error were 91.0.4472.88 and 90.0.4430.210.
@taylor-kn , we have released a major new version for @aws-amplify/ui-react@2.1.0, we havent been able to reproduce your issue in our latest release. Please let us know if you are still having any problems, we are here to help :)
Before opening, please confirm:
I have searched for duplicate or closed issues and discussions. I have read the guide for submitting bug reports. I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
When using the formFields prop to hide the phone number attribute on AmplifySignUp and AmplifySignIn UI components, the components throw the "Username cannot be empty" error despite the user entering the necessary information to sign up/in. This error only happens on Chrome on Android phones. The components work properly when using: -Chrome, Firefox and Safari on desktop -Firefox on Android phones -Chrome on iPhone -Opera mini and Firefox on Android phones
Package versions used: @aws-amplify/ui-react: 1.0.6 aws-amplify: 3.3.26
Note:
Using Hub.listen('UI Auth', (data) => { ... }) to listen for toast errors and display the errors with a modal.
Expected behavior
Should not throw the "Username cannot be empty" error and prevent user from logging in when the user has provided an email address and password. Note: this only happens on Chrome on Android phones. Developers should be able to use the formField prop on the AmplifySignIn and AmplifySignUp components to hide the phone number or use custom labels.
Reproduction steps
Code Snippet
Code that throws the error:
Code that works:
Code to display toast errors:
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
Android phones
Mobile Operating System
No response
Mobile Browser
Chrome
Mobile Browser Version
No response
Additional information and screenshots
No response