Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/tall-roses-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Make the instant password field focusable if it is autofilled.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export function _SignInStart(): JSX.Element {
const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> }) => {
const [autofilled, setAutofilled] = useState(false);
const ref = useRef<HTMLInputElement>(null);
const show = !!(autofilled || field?.value);

// show password if it's autofilled by the browser
useLayoutEffect(() => {
Expand Down Expand Up @@ -373,14 +374,12 @@ const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> })
return (
<Form.ControlRow
elementId={field.id}
sx={
!field.value && !autofilled ? { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' } : undefined
}
sx={show ? undefined : { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' }}
>
<Form.PasswordInput
{...field.props}
ref={ref}
tabIndex={!field.value ? -1 : undefined}
tabIndex={show ? undefined : -1}
/>
</Form.ControlRow>
);
Expand Down
7 changes: 3 additions & 4 deletions packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export function _SignInStart(): JSX.Element {
const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> }) => {
const [autofilled, setAutofilled] = useState(false);
const ref = useRef<HTMLInputElement>(null);
const show = !!(autofilled || field?.value);

// show password if it's autofilled by the browser
useLayoutEffect(() => {
Expand Down Expand Up @@ -373,14 +374,12 @@ const InstantPasswordRow = ({ field }: { field?: FormControlState<'password'> })
return (
<Form.ControlRow
elementId={field.id}
sx={
!field.value && !autofilled ? { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' } : undefined
}
sx={show ? undefined : { opacity: 0, height: 0, pointerEvents: 'none', marginTop: '-1rem' }}
>
<Form.PasswordInput
{...field.props}
ref={ref}
tabIndex={!field.value ? -1 : undefined}
tabIndex={show ? undefined : -1}
/>
</Form.ControlRow>
);
Expand Down