useModalForm show() doesn't do anything after modal is opened and closed once

title
16 Replies
kapa.ai
kapa.ai2y ago
Hi @ganuzaz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but your question seems incomplete. Could you please provide more details or context? I'm here to provide information about refine, a React-based framework for building data-intensive applications. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2y ago
<@149140198213550080> kapa.ai is still learning and improving, please let us know how it did by reacting below
optimistic-gold
optimistic-goldOP2y ago
@kapa.ai show() from useModalForm won't open the modal after the modal is being opened and closed once
kapa.ai
kapa.ai2y ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the information provided in the extracts, the show() function from useModalForm is used to open the modal. However, there's no specific information about any issues with reopening the modal after it has been opened and closed once. Here's a basic usage example of show() from useModalForm:
const { modalProps, formProps, show } = useModalForm();

return (
<>
<Button type="primary" onClick={() => show()}>
Show Modal
</Button>
<Modal
{...modalProps}
footer={[
<Button key="submit" type="primary" onClick={submit}>
Submit
</Button>,
]}
>
<Form {...formProps} onFinish={onFinishHandler} layout="vertical">
<Form.Item label="Title" name="title">
<Input />
</Form.Item>
</Form>
</Modal>
</>
);
const { modalProps, formProps, show } = useModalForm();

return (
<>
<Button type="primary" onClick={() => show()}>
Show Modal
</Button>
<Modal
{...modalProps}
footer={[
<Button key="submit" type="primary" onClick={submit}>
Submit
</Button>,
]}
>
<Form {...formProps} onFinish={onFinishHandler} layout="vertical">
<Form.Item label="Title" name="title">
<Input />
</Form.Item>
</Form>
</Modal>
</>
);
(Source: Refine Documentation (https://refine.dev/docs/api-reference/antd/hooks/form/useModalForm)) If you're experiencing issues with reopening the modal, it might be due to a specific implementation detail or a bug. I would recommend checking your implementation against the documentation and examples provided by Refine. If the issue persists, consider reaching out to the Refine community or support for more specific guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2y ago
<@149140198213550080> kapa.ai is still learning and improving, please let us know how it did by reacting below
optimistic-gold
optimistic-goldOP2y ago
doing show(id) works for some reason, but if there is no id it will only show the modal once.. weird
extended-salmon
extended-salmon2y ago
Hey @ganuzaz I don't understand what the problem is. Can you please attach a codesanbox with this problem?
optimistic-gold
optimistic-goldOP2y ago
w8, wrong link
optimistic-gold
optimistic-goldOP2y ago
go to a post show page click edit modal close the modal and click again the edit modal button it won't open the second time unless i used
const { params, id } = useParsed()
show(id)
const { params, id } = useParsed()
show(id)
extended-salmon
extended-salmon2y ago
You need to pass id in edit mode. Like this: onClick={() => { show(record?.id)}}
optimistic-gold
optimistic-goldOP2y ago
Yes, but it works when i open the modal the first time and it seems like its not the intended behavior
extended-salmon
extended-salmon2y ago
I did not see a problem when id was passed.
optimistic-gold
optimistic-goldOP2y ago
yea i know im just telling you that it seems weird that when id is not passed its still works but only for the first time the modal is opened
extended-salmon
extended-salmon2y ago
I'll find out why. It's interesting. We have to remember that you always need an id for edit mode.

Did you find this page helpful?