Render button _action value as hidden input

This commit is contained in:
Kalle
2023-08-15 00:05:01 +03:00
parent a6ba230568
commit 2bc325d8e8

View File

@@ -32,16 +32,24 @@ export function SubmitButton({
return undefined;
};
// render action as hidden input to deal with a bug in older Safari versions
const isActionValue = name() === "_action";
return (
<Button
{...rest}
disabled={rest.disabled || isSubmitting}
type="submit"
name={name()}
value={value()}
data-testid={testId ?? "submit-button"}
>
{children}
</Button>
<>
{isActionValue ? (
<input type="hidden" name="_action" value={_action} />
) : null}
<Button
{...rest}
disabled={rest.disabled || isSubmitting}
type="submit"
name={!isActionValue ? name() : undefined}
value={!isActionValue ? value() : undefined}
data-testid={testId ?? "submit-button"}
>
{children}
</Button>
</>
);
}