question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEAT] Make implementing "save and continue editing" button easier

See original GitHub issue

See discussion on Discord

Is your feature request related to a problem? Please describe. Django-Admin implements two buttons on its edit pages: “Save” and “Save and continue editing”. The latter is sorely missed in Refine.

Describe the solution you’d like As discussed on Discord, a possible solution would be to have useForm return a mutation function, which can be combined with { redirect: false } option and actionButtons on <Edit> to build both buttons.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
rassiecommented, Mar 9, 2022

I think this looks good for a simple solution. But I also feel this can be simplified a bit, for better DX.

list("posts") is basically what useForm({ redirect: "list" }) is doing, but with an additional burden to explicitly name the resource in question. Yes, we are writing code for a particular resource, but to have to type its name only a couple of times in code is a feature not a bug. Also, form.getFieldsValue(true) could probably be a default argument value, since both onFinish and form come from useForm, i.e. are available in the same scope. Then we’d arrive at this:

const { form, onFinish, redirect } = useForm<IPost>({
             automaticRedirect: false,
         });

actionButtons={
                 <>
                     <SaveButton
                         onClick={async() => {
                             await onFinish?.();
                         }}
                     >
                         Save and continue editing
                     </SaveButton>
                     <SaveButton
                         onClick={() => {
                             onFinish?.().then(redirect);
                         }}
                     />
                 </>
             }

But then again, <SaveButton> is a Refine component, so if we use all defaults, we might be talking about

const { form } = useForm<IPost>();

actionButtons={
                 <>
                     <SaveButton redirect={false}>
                         Save and continue editing
                     </SaveButton>
                     <SaveButton />
                 </>
             }

but I’m not sure whether this would be easy to implement, since <SaveButton> doesn’t handle redirect and probably shouldn’t.

1reaction
omeraplakcommented, Mar 15, 2022

Ohh, thank you. I’ve fixed it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement a save page and continue editing option - Jira
This should be easy to implement: Create a new save button that does the same as the existing one, minus reloading the page....
Read more >
Trying to make Save & Continue Editing button. How can I tell ...
I already have an Edit button that just appends the &e=T parameter to the current item page. But im going to use SQL...
Read more >
Save buttons that don't save - User Experience Stack Exchange
If I understand you correctly, you have a window that automatically saves changes for the user as they adjust items. Currently you have...
Read more >
How to "save and continue editing" a task in django-viewflow
I'm building an approval workflow using django-viewflow and django-material. A key component of the workflow is for the end user to fill in ......
Read more >
Saving Button Designs to Edit or Print - YouTube
Button Maker Software - BAB 6.0. Save to Edit - Saving Button Designs to Edit or Print - Build-a- Button Design Software.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found