Skip to content

Conversation

josh1643
Copy link

@josh1643 josh1643 commented Jun 6, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

The useEditableTable hook does not support the warnWhenUnsavedChanges prop, even though it’s supported in useForm.

What is the new behavior?

You can now pass warnWhenUnsavedChanges to useEditableTable, and it will work the same way as in useForm, showing a confirmation when navigating away with unsaved changes.

fixes #6811

Notes for reviewers

@josh1643 josh1643 requested a review from a team as a code owner June 6, 2025 15:13
Copy link

changeset-bot bot commented Jun 6, 2025

🦋 Changeset detected

Latest commit: d418862

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

This PR includes changesets to release 1 package
Name Type
@refinedev/core Minor

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

Copy link

netlify bot commented Jun 6, 2025

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

Built without sensitive environment variables

Name Link
🔨 Latest commit d418862
🔍 Latest deploy log https://app.netlify.com/projects/refine-doc-live-previews/deploys/6843058b6ac0090009d5af86
😎 Deploy Preview https://deploy-preview-6831--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.

@josh1643 josh1643 changed the title feat(core): add warnWhenUnsavedChanges to useEditableTable #6811 feat(core): add warnWhenUnsavedChanges to useEditableTable Jun 6, 2025
Comment on lines +96 to +107
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);
Copy link
Member

@alicanerdurmaz alicanerdurmaz Jun 20, 2025

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") {
Copy link
Member

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?

Copy link

stale bot commented Aug 19, 2025

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.

@stale stale bot added the wontfix This will not be worked on label Aug 19, 2025
@stale stale bot closed this Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] warnWhenUnsavedChanges prop for useEditableTable
2 participants