diff --git a/.changeset/fair-bars-agree.md b/.changeset/fair-bars-agree.md new file mode 100644 index 00000000000..3541756a911 --- /dev/null +++ b/.changeset/fair-bars-agree.md @@ -0,0 +1,7 @@ +--- +'@clerk/shared': patch +--- + + +Improve layout behaviour with ``. +- Disables Stripe's loader, and promotes the usage of the `fallback` prop. diff --git a/.changeset/vast-hoops-teach.md b/.changeset/vast-hoops-teach.md new file mode 100644 index 00000000000..e0b83a2caa0 --- /dev/null +++ b/.changeset/vast-hoops-teach.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Improve CLS when PaymentElement mounts in Checkout. diff --git a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx index c6e04711752..cf91e1c8f7e 100644 --- a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx +++ b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx @@ -19,6 +19,7 @@ import { handleError } from '@/ui/utils/errorHandler'; import { useSubscriberTypeContext, useSubscriberTypeLocalizationRoot } from '../../contexts'; import { descriptors, Flex, localizationKeys, Spinner, useAppearance, useLocalizations } from '../../customizables'; import type { LocalizationKey } from '../../localization'; +import { PaymentElementSkeleton } from './PaymentElementSkeleton'; const useStripeAppearance = (node: HTMLElement | null) => { const theme = useAppearance().parsedInternalTheme; @@ -231,7 +232,7 @@ const AddPaymentSourceForm = ({ children }: PropsWithChildren) => { })} > {children} - + } /> {card.error} [0]) => { + return ( + ({ + height: t.space.$2, + width: '100%', + borderRadius: t.radii.$md, + background: t.colors.$neutralAlpha100, + }), + props.sx, + ]} + /> + ); +}; + +const SkeletonInput = () => { + return ( + ({ + height: t.space.$10, + width: '100%', + })} + /> + ); +}; + +const LineGroup = (props: PropsWithChildren) => { + return ( + + {props.children} + + ); +}; + +const PaymentElementSkeleton = () => { + return ( + + + + ({ + height: t.space.$3, + width: t.sizes.$24, + })} + /> + + + + + + ({ + height: t.space.$3, + width: t.sizes.$20, + })} + /> + + + + + ({ + height: t.space.$3, + width: t.sizes.$24, + })} + /> + + + + + + + ({ + height: t.space.$3, + width: t.sizes.$16, + })} + /> + + + + + + + + + + + + ); +}; + +export { PaymentElementSkeleton }; diff --git a/packages/shared/src/react/commerce.tsx b/packages/shared/src/react/commerce.tsx index 4239585d108..8411dd762d3 100644 --- a/packages/shared/src/react/commerce.tsx +++ b/packages/shared/src/react/commerce.tsx @@ -206,6 +206,7 @@ const PaymentElementInternalRoot = (props: PropsWithChildren) => { key={externalClientSecret} stripe={stripe} options={{ + loader: 'never', clientSecret: externalClientSecret, appearance: { variables: stripeAppearance, diff --git a/packages/shared/src/react/stripe-react/index.tsx b/packages/shared/src/react/stripe-react/index.tsx index 722237d53c4..94006e3b21b 100644 --- a/packages/shared/src/react/stripe-react/index.tsx +++ b/packages/shared/src/react/stripe-react/index.tsx @@ -429,6 +429,10 @@ const createElementComponent = (type: StripeElementType, isServer: boolean): Fun {!isReady && fallback}