diff --git a/.changeset/nice-starfishes-itch.md b/.changeset/nice-starfishes-itch.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/nice-starfishes-itch.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/clerk-js/src/ui.retheme/elements/FieldControl.tsx b/packages/clerk-js/src/ui.retheme/elements/FieldControl.tsx index 7217b81e87..3fe035e67d 100644 --- a/packages/clerk-js/src/ui.retheme/elements/FieldControl.tsx +++ b/packages/clerk-js/src/ui.retheme/elements/FieldControl.tsx @@ -17,7 +17,6 @@ import { import { FormFieldContextProvider, sanitizeInputProps, useFormField } from '../primitives/hooks'; import type { PropsOfComponent } from '../styledSystem'; import type { useFormControl as useFormControlUtil } from '../utils'; -import { useFormControlFeedback } from '../utils'; import { OTPCodeControl, OTPInputDescription, OTPInputLabel, OTPResendButton, OTPRoot } from './CodeControl'; import { useCardState } from './contexts'; import type { FormFeedbackProps } from './FormControl'; @@ -32,20 +31,13 @@ type FormControlProps = Omit, 'label' | 'placehol const Root = (props: PropsWithChildren) => { const card = useCardState(); - const { children, feedbackType, feedback, isFocused, isDisabled: isDisabledProp, ...restProps } = props; - - /** - * Debounce the feedback before passing it inside the provider. - */ - const { debounced: debouncedState } = useFormControlFeedback({ feedback, feedbackType, isFocused }); + const { children, isDisabled: isDisabledProp, ...restProps } = props; const isDisabled = isDisabledProp || card.isLoading; const ctxProps = { ...restProps, isDisabled, - isFocused, - ...debouncedState, }; return {children}; @@ -163,13 +155,12 @@ const FieldLabelRow = (props: PropsWithChildren) => { }; const FieldFeedback = (props: Pick) => { - const { feedback, feedbackType, isFocused, fieldId } = useFormField(); - const { debounced } = useFormControlFeedback({ feedback, feedbackType, isFocused }); + const { fieldId, debouncedFeedback } = useFormField(); return ( >['props'] & { isDisabled: boolean; @@ -13,13 +14,14 @@ type FormFieldContextValue = Omit & { id?: string; fieldId?: FieldId; hasError: boolean; + debouncedFeedback: ReturnType['debounced']; }; /** * Extract the context hook without the guarantee in order to avoid throwing errors if our field/form primitives are not wrapped inside a Field.Root component. * In case our primitives need to always be wrapped with Field.Root, consider updating the following line to [FormFieldContext, useFormField] */ -export const [FormFieldContext, _, useFormField] = createContextAndHook('FormFieldContext'); +export const [FormFieldContext, , useFormField] = createContextAndHook('FormFieldContext'); export const FormFieldContextProvider = (props: React.PropsWithChildren) => { const { @@ -34,12 +36,23 @@ export const FormFieldContextProvider = (props: React.PropsWithChildren diff --git a/packages/clerk-js/src/ui/elements/FieldControl.tsx b/packages/clerk-js/src/ui/elements/FieldControl.tsx index 7217b81e87..3fe035e67d 100644 --- a/packages/clerk-js/src/ui/elements/FieldControl.tsx +++ b/packages/clerk-js/src/ui/elements/FieldControl.tsx @@ -17,7 +17,6 @@ import { import { FormFieldContextProvider, sanitizeInputProps, useFormField } from '../primitives/hooks'; import type { PropsOfComponent } from '../styledSystem'; import type { useFormControl as useFormControlUtil } from '../utils'; -import { useFormControlFeedback } from '../utils'; import { OTPCodeControl, OTPInputDescription, OTPInputLabel, OTPResendButton, OTPRoot } from './CodeControl'; import { useCardState } from './contexts'; import type { FormFeedbackProps } from './FormControl'; @@ -32,20 +31,13 @@ type FormControlProps = Omit, 'label' | 'placehol const Root = (props: PropsWithChildren) => { const card = useCardState(); - const { children, feedbackType, feedback, isFocused, isDisabled: isDisabledProp, ...restProps } = props; - - /** - * Debounce the feedback before passing it inside the provider. - */ - const { debounced: debouncedState } = useFormControlFeedback({ feedback, feedbackType, isFocused }); + const { children, isDisabled: isDisabledProp, ...restProps } = props; const isDisabled = isDisabledProp || card.isLoading; const ctxProps = { ...restProps, isDisabled, - isFocused, - ...debouncedState, }; return {children}; @@ -163,13 +155,12 @@ const FieldLabelRow = (props: PropsWithChildren) => { }; const FieldFeedback = (props: Pick) => { - const { feedback, feedbackType, isFocused, fieldId } = useFormField(); - const { debounced } = useFormControlFeedback({ feedback, feedbackType, isFocused }); + const { fieldId, debouncedFeedback } = useFormField(); return ( >['props'] & { isDisabled: boolean; @@ -13,12 +14,14 @@ type FormFieldContextValue = Omit & { id?: string; fieldId?: FieldId; hasError: boolean; + debouncedFeedback: ReturnType['debounced']; }; + /** * Extract the context hook without the guarantee in order to avoid throwing errors if our field/form primitives are not wrapped inside a Field.Root component. * In case our primitives need to always be wrapped with Field.Root, consider updating the following line to [FormFieldContext, useFormField] */ -export const [FormFieldContext, _, useFormField] = createContextAndHook('FormFieldContext'); +export const [FormFieldContext, , useFormField] = createContextAndHook('FormFieldContext'); export const FormFieldContextProvider = (props: React.PropsWithChildren) => { const { @@ -33,12 +36,23 @@ export const FormFieldContextProvider = (props: React.PropsWithChildren