I’ve this part, it’s imagined to work as some type of extra-entering-dialog.
It’s imported in Edit operate of the block.
/**
* Element for coming into biography
*/
import { InnerBlocks } from '@wordpress/block-editor';
import { Button } from '@wordpress/parts';
import { useState } from '@wordpress/component';
const BiographyModal = ({ title }) => {
const [ isOpen, setIsOpen ] = useState(false);
const modal =
<div className="biography-modal">
<h3>{ `Životopis ${ title }` }</h3>
<InnerBlocks />
<Button isDefault onClick={ () => setIsOpen({ isOpen: false }) }>
Završi uređivanje
</Button>
</div>;
return (
<div>
<Button isDefault onClick={ () => setIsOpen({ isOpen: true }) }>Uredi životopis</Button>
{ isOpen && modal }
</div>
)
}
export default BiographyModal;
It does open on button decrease in code, however it doesn’t shut when clicking on button greater in code. It will not even shut after I change state of isOpen by utilizing React developer instruments in browser. At first I believed this was as a result of dismounting of InnerBlocks or Button shouldn’t be allowed, however after I take away these two (and provides decrease button chance to operate as toggle button (setIsOpen({ isOpen: ! isOpen })
), this nonetheless doesn’t shut. Any clues?