mere-teal
mere-teal2mo ago

I ran into something I believe is a doc

I ran into something I believe is a doc issue yesterday (or possibly a bug) with useModalForm from @refinedev/antd. I implemented a form where I need to do a file upload upon submitting the form, so I provided my own method to onFinish in the Form component. Based on the doc (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-modal-form/#close), I thought I could call onFinish and then close. But I ran into some strange behaviors: 1. The user sees the dialog about unsaved changes, which seems like a problem on its own. 2. If they click cancel, they get correctly returned to the dialog. 3. If they click OK (i.e., OK to discard changes), it ends up updating the resource anyway, which I can confirm from PUT/PATCH calls being made by the browser. I realized after much trial and error that the right method to call is not onFinish from useModalForm, but onFinish from the formProps. Furthermore, I don't need to call close since onFinish is at the end and it seems to close the dialog fine on its own. So a couple questions: 1. Is the doc I linked above a valid sample? it seems like even if onFinish from useModalForm is the right method to call, the close call would be irrelevant. 2. Why is onFinish from useModalForm not the same from formProps? Based on the doc (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-modal-form/#close), it says the only different is bassing value is mandatory, but in my instance this is a clear difference in behavior.
2 Replies
flat-fuchsia
flat-fuchsia2mo ago
Hello @AbuQ, thanks for the detailed explanation. It looks like you've found a bug. Could you open a GitHub issue with a reproducible example? It's easier to track bugs through GitHub.
national-gold
national-gold2mo ago