Skip to content

[✨] action$ actionPath url params behave differently for <Form> vs <form> #94

Closed
@tuurbo

Description

@tuurbo

Is your feature request related to a problem?

When submitting a form with <Form action={useAction} /> the actionPath keeps the current urls search params. If you submit a form with <form action={useAction.actionPath} /> you lose the urls search params.

To keep url search params, i currently have to append to the formAction.actionPath

export const useAction = action$((formData, { url }) => {
  return {
    success: true,
  };
});

<form action={formAction.actionPath + '&foo=111'} method="post">
  <button>submit</button>
</form>

Describe the solution you'd like

Should both ways of submitting a form behave the same? If so, maybe allow passing an option to disable keeping params (not sure if there is a use case for this)?

const formAction = useAction({
  preserveUrlSearchParams: false,
});

Describe alternatives you've considered

Also, for a separate issue, maybe there is a use case for an option like this?

const formAction = useAction({
  dangerouslyAllowCrossSite: true,
});

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions