Skip to content

Commit 7b1e9e0

Browse files
fix (design library): do not insert a new design library block if there is already one present
1 parent 00d7dd3 commit 7b1e9e0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/plugins/design-library-button/design-library-button.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ const DesignLibraryButton = () => {
1717
const { getEditorDom } = useSelect( 'stackable/editor-dom' )
1818

1919
const onClick = useCallback( () => {
20+
// If there's a design library block already in the editor, just open it.
21+
if ( getEditorDom()?.querySelector( '[data-type="stackable/design-library"]' ) ) {
22+
const button = getEditorDom()?.querySelector( `[data-type="stackable/design-library"] button` )
23+
// Open the design library.
24+
if ( button ) {
25+
button.click()
26+
}
27+
return
28+
}
29+
2030
// Insert a design library block.
2131
const block = createBlock( 'stackable/design-library' )
2232

0 commit comments

Comments
 (0)