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