admin管理员组文章数量:1122832
In my WordPress plugin, a Modal gets opened from within the Block Editor when a button is clicked.
const MyContent = () => {
const [isOpen, setOpen] = useState(false);
const openModal = () => setOpen(true);
const closeModal = () => setOpen(false);
return (
<>
<Button variant="primary" icon={check} onClick={openModal}>
Open Modal
</Button>
{isOpen && (
<Modal title="Spellcheck" size='fill' onRequestClose={closeModal}>
<!-- Modal content here -->
<Button variant="secondary" onClick={closeModal} style={ButtonStyle}>
Close Modal
</Button>
</Modal>
)}
</>
);
};
I'd like to trigger an action when the Modal becomes visible to the user.
But I don't know which event I should listen to. In the docs I didn't find anything. Using monitorEvents($0)
in the dev tools also didn't bring up anything useful.
Is there any event which is fired when the Modal becomes visible?
本文标签: plugin developmentEvent when Modal is openedvisible
版权声明:本文标题:plugin development - Event when Modal is openedvisible 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303056a1931753.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论