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(ui): Ensure optional hints are not shown in sign in flow #3747

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 1 addition & 7 deletions packages/ui/src/common/email-or-phone-number-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ export function EmailOrPhoneNumberField({
labelEmail = 'Email address',
labelPhoneNumber = 'Phone number',
locationBasedCountryIso,
requiredEmail,
requiredPhoneNumber,
Comment on lines -16 to -17
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing the separate required props as there is not a use where one is required and the other is not in sign in flow.

toggleLabelEmail = 'Use email',
toggleLabelPhoneNumber = 'Use phone',
...props
}: {
labelEmail?: React.ReactNode;
labelPhoneNumber?: React.ReactNode;
locationBasedCountryIso: React.ComponentProps<typeof PhoneNumberField>['locationBasedCountryIso'];
requiredEmail?: boolean;
requiredPhoneNumber?: boolean;
toggleLabelEmail?: string;
toggleLabelPhoneNumber?: string;
} & Omit<React.ComponentProps<typeof Common.Input>, 'required' | 'type'>) {
} & Omit<React.ComponentProps<typeof Common.Input>, 'type'>) {
const [showPhoneNumberField, setShowPhoneNumberField] = React.useState(false);

const toggle = (
Expand All @@ -44,7 +40,6 @@ export function EmailOrPhoneNumberField({
label={labelPhoneNumber}
locationBasedCountryIso={locationBasedCountryIso}
alternativeFieldTrigger={toggle}
required={requiredPhoneNumber}
name={name}
{...props}
/>
Expand All @@ -54,7 +49,6 @@ export function EmailOrPhoneNumberField({
name={name}
label={labelEmail}
alternativeFieldTrigger={toggle}
required={requiredEmail}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ export function EmailOrUsernameOrPhoneNumberField({
labelEmailOrUsername = 'Email address or username',
labelPhoneNumber = 'Phone number',
locationBasedCountryIso,
requiredEmailOrUsername,
requiredPhoneNumber,
toggleDescription = 'Toggle between email or username, and phone.',
...props
}: {
labelEmailOrUsername?: React.ReactNode;
labelPhoneNumber?: React.ReactNode;
locationBasedCountryIso: React.ComponentProps<typeof PhoneNumberField>['locationBasedCountryIso'];
requiredEmailOrUsername?: boolean;
requiredPhoneNumber?: boolean;
toggleDescription?: string;
} & Omit<React.ComponentProps<typeof Common.Input>, 'type'>) {
const [showPhoneNumberField, setShowPhoneNumberField] = React.useState(false);
Expand All @@ -44,7 +40,6 @@ export function EmailOrUsernameOrPhoneNumberField({
name={name}
locationBasedCountryIso={locationBasedCountryIso}
alternativeFieldTrigger={toggle}
required={requiredPhoneNumber}
{...props}
/>
) : (
Expand All @@ -53,7 +48,6 @@ export function EmailOrUsernameOrPhoneNumberField({
name={name}
label={labelEmailOrUsername}
alternativeFieldTrigger={toggle}
required={requiredEmailOrUsername}
/>
);
}
7 changes: 7 additions & 0 deletions packages/ui/src/components/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ export function SignInComponentLoaded() {
<EmailField
name='identifier'
disabled={isGlobalLoading}
required
/>
) : null}

{usernameEnabled && !emailAddressEnabled && !phoneNumberEnabled ? (
<UsernameField
name='identifier'
disabled={isGlobalLoading}
required
/>
) : null}

Expand All @@ -95,13 +97,15 @@ export function SignInComponentLoaded() {
name='identifier'
disabled={isGlobalLoading}
locationBasedCountryIso={locationBasedCountryIso}
required
/>
) : null}

{emailAddressEnabled && usernameEnabled && !phoneNumberEnabled ? (
<EmailOrUsernameField
name='identifier'
disabled={isGlobalLoading}
required
/>
) : null}

Expand All @@ -110,6 +114,7 @@ export function SignInComponentLoaded() {
name='identifier'
disabled={isGlobalLoading}
locationBasedCountryIso={locationBasedCountryIso}
required
/>
) : null}

Expand All @@ -118,6 +123,7 @@ export function SignInComponentLoaded() {
name='identifier'
disabled={isGlobalLoading}
locationBasedCountryIso={locationBasedCountryIso}
required
/>
) : null}

Expand All @@ -126,6 +132,7 @@ export function SignInComponentLoaded() {
name='identifier'
disabled={isGlobalLoading}
locationBasedCountryIso={locationBasedCountryIso}
required
/>
) : null}
</div>
Expand Down
Loading