Skip to content

Conversation

@gmpaliwal07
Copy link

@gmpaliwal07 gmpaliwal07 commented Oct 28, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

The commit message follows our guidelines: https://refine.dev/docs/guides-concepts/contributing/#commit-convention

Bugs / Features

  • What is the current behavior?
  • useForm always redirects after a successful mutation — even when used in modals, drawers, or inline forms — breaking the intended UX.
  • Users previously had to pass: redirect: false
  • but it was inconsistent and still required redirectOnSuccess in some cases.

Issue: #6934

What is the new behavior?
Now, you can disable redirect with a single, clear prop:
useForm({
redirectOnSuccess: false
})

Benefits:
✅ No redirect after success
✅ Works in modals, drawers, inline forms
✅ redirect?: RedirectAction still works (for custom targets)
✅ redirectOnSuccess?: boolean defaults to true → no breaking changes

Notes for Reviewers

Optional prop — safe for all existing code
Fully typed
Manually tested in examples/base-antd:

redirectOnSuccess: false → stays on page
Default → redirects to list

Fixes #6934

@gmpaliwal07 gmpaliwal07 requested a review from a team as a code owner October 28, 2025 14:30
@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: 7715077

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Oct 28, 2025

Deploy Preview for refine-doc-live-previews ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7715077
🔍 Latest deploy log https://app.netlify.com/projects/refine-doc-live-previews/deploys/6900d37f60d13d000820070d
😎 Deploy Preview https://deploy-preview-7096--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@alicanerdurmaz alicanerdurmaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @gmpaliwal07, I left comment to the issue. What do you think?

@gmpaliwal07
Copy link
Author

gmpaliwal07 commented Nov 4, 2025

Hello @alicanerdurmaz ,

As per my understanding redirect: false only changes the target - it does not prevent the internal redirect() call.
Even with redirect: false, navigation is triggered in useRedirectionAfterSubmission.

redirect: false -> still goes to list (default fallback)

redirectOnSuccess: false adds an early return in the redirect hook -> fully stopping navigation.

This is required for modals, drawers, and inline forms where any redirect breaks UX.

Without it, users must fight the framework. With it: one clean prop.

(Alternative - removing default fallback would break existing apps. Not safe.)

Looking forward to feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Make useForm success redirect optional

2 participants