diff --git a/apps/remix/app/components/dialogs/sign-field-number-dialog.tsx b/apps/remix/app/components/dialogs/sign-field-number-dialog.tsx index 3df56b0e4..613bdd1e5 100644 --- a/apps/remix/app/components/dialogs/sign-field-number-dialog.tsx +++ b/apps/remix/app/components/dialogs/sign-field-number-dialog.tsx @@ -20,10 +20,15 @@ import { z } from 'zod'; export type SignFieldNumberDialogProps = { fieldMeta: TNumberFieldMeta; + + /** + * The current value of the field. When set, an empty submit is allowed so the signer can clear the field. + */ + defaultValue?: string; }; export const SignFieldNumberDialog = createCallable( - ({ call, fieldMeta }) => { + ({ call, fieldMeta, defaultValue }) => { const { t } = useLingui(); // Needs to be inside dialog for translation purposes. @@ -83,14 +88,16 @@ export const SignFieldNumberDialog = createCallable>({ resolver: zodResolver(ZSignFieldNumberFormSchema), defaultValues: { - number: undefined, + number: defaultValue, }, }); diff --git a/apps/remix/app/components/dialogs/sign-field-text-dialog.tsx b/apps/remix/app/components/dialogs/sign-field-text-dialog.tsx index d651282ed..03d9b64da 100644 --- a/apps/remix/app/components/dialogs/sign-field-text-dialog.tsx +++ b/apps/remix/app/components/dialogs/sign-field-text-dialog.tsx @@ -26,75 +26,84 @@ type TSignFieldTextFormSchema = z.infer; export type SignFieldTextDialogProps = { fieldMeta?: TTextFieldMeta; + + /** + * The current value of the field. When set, an empty submit is allowed so the signer can clear the field. + */ + defaultValue?: string; }; -export const SignFieldTextDialog = createCallable(({ call, fieldMeta }) => { - const { t } = useLingui(); +export const SignFieldTextDialog = createCallable( + ({ call, fieldMeta, defaultValue }) => { + const { t } = useLingui(); - const form = useForm({ - resolver: zodResolver(ZSignFieldTextFormSchema), - defaultValues: { - text: '', - }, - }); + const form = useForm({ + resolver: zodResolver(defaultValue ? z.object({ text: z.string() }) : ZSignFieldTextFormSchema), + defaultValues: { + text: defaultValue ?? '', + }, + }); - return ( - (!value ? call.end(null) : null)}> - - - {fieldMeta?.label || Enter Text} + return ( + (!value ? call.end(null) : null)}> + + + {fieldMeta?.label || Enter Text} - - Please enter a value - - + + Please enter a value + + -
- call.end(data.text))}> -
- ( - - -