mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
fix: auto-sign after value change
This commit is contained in:
@ -43,7 +43,7 @@ export const InitialsField = ({
|
||||
const { fullName } = useRequiredSigningContext();
|
||||
const initials = extractInitials(fullName);
|
||||
|
||||
const debouncedTerm = useDebouncedValue(initials, 5000);
|
||||
const debouncedTerm = useDebouncedValue(initials, 2000);
|
||||
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
@ -123,13 +123,13 @@ export const InitialsField = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!field.inserted && fullName) {
|
||||
if (!field.inserted && debouncedTerm) {
|
||||
void executeActionAuthProcedure({
|
||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||
actionTarget: field.type,
|
||||
});
|
||||
}
|
||||
}, [field, debouncedTerm]);
|
||||
}, [field, debouncedTerm, field.inserted]);
|
||||
|
||||
return (
|
||||
<SigningFieldContainer field={field} onSign={onSign} onRemove={onRemove} type="Initials">
|
||||
|
||||
@ -6,6 +6,7 @@ import { useRouter } from 'next/navigation';
|
||||
|
||||
import { Loader } from 'lucide-react';
|
||||
|
||||
import { useDebouncedValue } from '@documenso/lib/client-only/hooks/use-debounced-value';
|
||||
import { DO_NOT_INVALIDATE_QUERY_ON_MUTATION } from '@documenso/lib/constants/trpc';
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import type { TRecipientActionAuth } from '@documenso/lib/types/document-auth';
|
||||
@ -41,6 +42,8 @@ export const NameField = ({ field, recipient, onSignField, onUnsignField }: Name
|
||||
const { fullName: providedFullName, setFullName: setProvidedFullName } =
|
||||
useRequiredSigningContext();
|
||||
|
||||
const debouncedProvidedFullName = useDebouncedValue(providedFullName, 2000);
|
||||
|
||||
const { executeActionAuthProcedure } = useRequiredDocumentAuthContext();
|
||||
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@ -155,7 +158,7 @@ export const NameField = ({ field, recipient, onSignField, onUnsignField }: Name
|
||||
actionTarget: field.type,
|
||||
});
|
||||
}
|
||||
}, [field]);
|
||||
}, [field, debouncedProvidedFullName]);
|
||||
|
||||
return (
|
||||
<SigningFieldContainer
|
||||
|
||||
Reference in New Issue
Block a user