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/device-code-input-overflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/ui': patch
---

Fix the `<OAuthDeviceVerification />` code input overflowing the card when the card is not flush.
6 changes: 6 additions & 0 deletions packages/clerk-js/sandbox/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const AVAILABLE_COMPONENTS = [
'apiKeys',
'configureSSO',
'oauthConsent',
'oauthDeviceVerification',
'taskChooseOrganization',
'taskResetPassword',
'taskSetupMFA',
Expand Down Expand Up @@ -154,6 +155,7 @@ const componentControls: Record<AvailableComponent, ComponentPropsControl> = {
apiKeys: buildComponentControls('apiKeys'),
configureSSO: buildComponentControls('configureSSO'),
oauthConsent: buildComponentControls('oauthConsent'),
oauthDeviceVerification: buildComponentControls('oauthDeviceVerification'),
taskChooseOrganization: buildComponentControls('taskChooseOrganization'),
taskResetPassword: buildComponentControls('taskResetPassword'),
taskSetupMFA: buildComponentControls('taskSetupMFA'),
Expand Down Expand Up @@ -425,6 +427,10 @@ void (async () => {
'/pricing-table': { mount: 'mountPricingTable', component: 'pricingTable' },
'/api-keys': { mount: 'mountAPIKeys', component: 'apiKeys' },
'/configure-sso': { mount: '__internal_mountConfigureSSO', component: 'configureSSO' },
'/oauth-device-verification': {
mount: '__internal_mountOAuthDeviceVerification',
component: 'oauthDeviceVerification',
},
'/task-choose-organization': {
mount: 'mountTaskChooseOrganization',
component: 'taskChooseOrganization',
Expand Down
5 changes: 5 additions & 0 deletions packages/clerk-js/sandbox/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@
label="OAuth Consent"
component="<OAuthConsent />"
></nav-link>
<nav-link
href="/oauth-device-verification"
label="OAuth Device Verification"
component="<OAuthDeviceVerification />"
></nav-link>
<nav-link
href="/api-keys"
label="API Keys"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type OAuthDeviceVerificationCodeInputProps = {
function CodeGroup({ slots, hasError }: { slots: SlotProps[]; hasError: boolean }) {
return (
<Flex
gap={2}
sx={t => ({ gap: t.space.$1x5 })}
hasError={hasError}
>
{slots.map((slot, index) => (
Expand All @@ -27,6 +27,7 @@ function CodeGroup({ slots, hasError }: { slots: SlotProps[]; hasError: boolean
key={index}
elementDescriptor={descriptors.otpCodeFieldInput}
hasError={hasError}
sx={t => ({ width: t.space.$8, height: t.space.$8 })}
{...slot}
/>
))}
Expand Down Expand Up @@ -70,7 +71,7 @@ export function OAuthDeviceVerificationCodeInput({ control }: OAuthDeviceVerific
<Flex
align='center'
elementDescriptor={descriptors.otpCodeFieldInputs}
gap={3}
gap={2}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
hasError={hasError}
justify='center'
role='group'
Expand Down
47 changes: 25 additions & 22 deletions packages/ui/src/elements/CodeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,34 +223,37 @@ export function OTPInputSlot(
props: SlotProps & PropsOfComponent<typeof OTPInputSegment> & { isSuccessfullyFilled?: boolean },
) {
const { isSuccessfullyFilled, ...otpProps } = props;
const { char, hasFakeCaret, isActive, placeholderChar, ...rest } = otpProps;
const { char, hasFakeCaret, isActive, placeholderChar, sx, ...rest } = otpProps;
return (
<OTPInputSegment
data-testid='otp-input-segment'
{...rest}
focusRing={isActive}
variant='default'
sx={t => ({
textAlign: 'center',
...common.textVariants(t).h2,
padding: `${t.space.$0x5} 0`,
boxSizing: 'border-box',
display: 'flex',
position: 'relative',
alignItems: 'center',
justifyContent: 'center',
height: t.space.$10,
width: t.space.$10,
color: t.colors.$colorInputForeground,
borderWidth: t.borderWidths.$normal,
borderRadius: t.radii.$md,
...(isSuccessfullyFilled ? { borderColor: t.colors.$success500 } : common.borderColor(t, props)),
backgroundColor: 'unset',
[mqu.sm]: {
height: t.space.$8,
width: t.space.$8,
},
})}
sx={[
t => ({
textAlign: 'center',
...common.textVariants(t).h2,
padding: `${t.space.$0x5} 0`,
boxSizing: 'border-box',
display: 'flex',
position: 'relative',
alignItems: 'center',
justifyContent: 'center',
height: t.space.$10,
width: t.space.$10,
color: t.colors.$colorInputForeground,
borderWidth: t.borderWidths.$normal,
borderRadius: t.radii.$md,
...(isSuccessfullyFilled ? { borderColor: t.colors.$success500 } : common.borderColor(t, props)),
backgroundColor: 'unset',
[mqu.sm]: {
height: t.space.$8,
width: t.space.$8,
},
}),
sx,
]}
>
{char !== null && <div>{char}</div>}
{hasFakeCaret && <FakeCaret />}
Expand Down
21 changes: 20 additions & 1 deletion packages/ui/src/elements/__tests__/CodeControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { describe, expect, it, vi } from 'vitest';

import { bindCreateFixtures } from '@/test/create-fixtures';

import { OTPCodeControl, OTPRoot, useFieldOTP } from '../CodeControl';
import { OTPCodeControl, OTPInputSlot, OTPRoot, useFieldOTP } from '../CodeControl';
import { withCardStateProvider } from '../contexts';

const { createFixtures } = bindCreateFixtures('UserProfile');
Expand Down Expand Up @@ -51,6 +51,25 @@ const typeCode = async (input: HTMLElement, user: UserEvent, code = '123456') =>
};

describe('CodeControl', () => {
describe('OTPInputSlot', () => {
it('allows its dimensions to be overridden', async () => {
const { wrapper } = await createFixtures();

const { getByTestId } = render(
<OTPInputSlot
char={null}
hasFakeCaret={false}
isActive={false}
placeholderChar={null}
sx={{ width: '2rem', height: '2rem' }}
/>,
{ wrapper },
);

expect(getByTestId(testId)).toHaveStyle({ width: '2rem', height: '2rem' });
});
});

describe('OTPCodeControl', () => {
it('renders 6 "fake" input fields by default', async () => {
const { wrapper } = await createFixtures();
Expand Down
Loading