Skip to content

Commit

Permalink
refactor(GCOM-1528): prevent overlap between autofilled data and inpu…
Browse files Browse the repository at this point in the history
…t label on the sign-in page
  • Loading branch information
carlocarels90 committed Nov 11, 2024
1 parent 7831a40 commit f2dad96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export function AccountSignInUpForm(props: AccountSignInUpFormProps) {
control={control}
name='email'
required
InputLabelProps={{ shrink: true }}
// Fixes an issue where the label doesn't shrink as expected when the field is autofilled by the browser.
// Using shrink based on the presence of 'email' forces the label to behave correctly even with autofill.
InputLabelProps={{ shrink: !!watch('email') }}
InputProps={{
endAdornment:
mode === 'session-expired' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function SignInForm(props: SignInFormProps) {

const form = useSignInForm({ email })

const { handleSubmit, required, formState, error, control } = form
const { handleSubmit, required, formState, error, control, watch } = form
const [remainingError, authError] = graphqlErrorByCategory({
category: 'graphql-authentication',
error,
Expand All @@ -35,7 +35,9 @@ export function SignInForm(props: SignInFormProps) {
required={required.password}
disabled={formState.isSubmitting}
helperText={!!formState.errors.password || authError?.message}
InputLabelProps={{ shrink: true }}
// Fixes an issue where the label doesn't shrink as expected when the field is autofilled by the browser.
// Using shrink based on the presence of 'password' forces the label to behave correctly even with autofill.
InputLabelProps={{ shrink: !!watch('password') }}
InputProps={{
endAdornment: (
<Link href='/account/forgot-password' underline='hover' sx={{ whiteSpace: 'nowrap' }}>
Expand Down

0 comments on commit f2dad96

Please sign in to comment.