-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(core): add warnWhenUnsavedChanges to useEditableTable #6831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d418862 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for refine-doc-live-previews ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
const { warnWhenUnsavedChanges, ...restProps } = props; | ||
|
||
const formProps: UseFormProps<TQueryFnData, TError, TVariables> = { | ||
...restProps, | ||
action: "edit", | ||
redirect: false, | ||
}); | ||
...(typeof warnWhenUnsavedChanges !== "undefined" | ||
? { warnWhenUnsavedChanges } | ||
: {}), | ||
}; | ||
|
||
const edit = useForm<TQueryFnData, TError, TVariables>(formProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is fine, but a smaller diff makes git history easier to read.
Can we keep it like this?
const edit = useForm<TQueryFnData, TError, TVariables>({
...props,
action: "edit",
redirect: false,
});
Since we pass all props, it works anyway.
const result = await edit.onFinish(values); | ||
if (autoSubmitClose) { | ||
setId(undefined); | ||
if (typeof edit.onFinish === "function") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain why this change is needed?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
The
useEditableTable
hook does not support thewarnWhenUnsavedChanges
prop, even though it’s supported inuseForm
.What is the new behavior?
You can now pass
warnWhenUnsavedChanges
touseEditableTable
, and it will work the same way as inuseForm
, showing a confirmation when navigating away with unsaved changes.fixes #6811
Notes for reviewers