Skip to content

Commit 3c0ea0a

Browse files
committed
fix(clerk-js): Make the instant password field focusable if autofilled
1 parent 1543301 commit 3c0ea0a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.changeset/tall-roses-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Make the instant password field focusable if it is autofilled.

packages/clerk-js/src/ui.retheme/components/SignIn/SignInStart.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export function _SignInStart(): JSX.Element {
341341
const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> }) => {
342342
const [autofilled, setAutofilled] = useState(false);
343343
const ref = useRef<HTMLInputElement>(null);
344+
const show = !!(autofilled || field?.value);
344345

345346
// show password if it's autofilled by the browser
346347
useLayoutEffect(() => {
@@ -373,14 +374,12 @@ const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> })
373374
return (
374375
<Form.ControlRow
375376
elementId={field.id}
376-
sx={
377-
!field.value && !autofilled ? { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' } : undefined
378-
}
377+
sx={show ? undefined : { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' }}
379378
>
380379
<Form.PasswordInput
381380
{...field.props}
382381
ref={ref}
383-
tabIndex={!field.value ? -1 : undefined}
382+
tabIndex={show ? undefined : -1}
384383
/>
385384
</Form.ControlRow>
386385
);

packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export function _SignInStart(): JSX.Element {
341341
const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> }) => {
342342
const [autofilled, setAutofilled] = useState(false);
343343
const ref = useRef<HTMLInputElement>(null);
344+
const show = !!(autofilled || field?.value);
344345

345346
// show password if it's autofilled by the browser
346347
useLayoutEffect(() => {
@@ -373,14 +374,12 @@ const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> })
373374
return (
374375
<Form.ControlRow
375376
elementId={field.id}
376-
sx={
377-
!field.value && !autofilled ? { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' } : undefined
378-
}
377+
sx={show ? undefined : { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' }}
379378
>
380379
<Form.PasswordInput
381380
{...field.props}
382381
ref={ref}
383-
tabIndex={!field.value ? -1 : undefined}
382+
tabIndex={show ? undefined : -1}
384383
/>
385384
</Form.ControlRow>
386385
);

0 commit comments

Comments
 (0)