Skip to content

Commit ad59d30

Browse files
committed
wip
1 parent 459c4a0 commit ad59d30

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/blocks/link-to-group.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const withToolbar = ( BlockEdit ) => ( props ) => {
4040
const { linkUrl, linkOpensInNewTab } = attributes;
4141

4242
const [ open, setOpen ] = useState( false );
43-
const buttonRef = useRef( null );
43+
const anchorRef = useRef( null );
4444
const linkWrapRef = useRef( null );
4545

4646
const value = { url: linkUrl || '', opensInNewTab: !!linkOpensInNewTab };
@@ -64,23 +64,25 @@ const withToolbar = ( BlockEdit ) => ( props ) => {
6464
{ isSelected && (
6565
<BlockControls>
6666
<ToolbarGroup>
67-
<ToolbarButton
68-
ref={ buttonRef }
69-
icon={ link }
70-
label={ __( 'Link', 'nfd-wonder-blocks' ) }
71-
onClick={ () => setOpen( ( isOpen ) => ! isOpen ) }
72-
isPressed={ open }
73-
/>
67+
<div ref={ anchorRef }>
68+
<ToolbarButton
69+
icon={ link }
70+
label={ __( 'Link', 'nfd-wonder-blocks' ) }
71+
onClick={ () => setOpen( ( isOpen ) => ! isOpen ) }
72+
isPressed={ open }
73+
/>
74+
</div>
7475
</ToolbarGroup>
7576
</BlockControls>
7677
) }
7778

78-
{ open && (
79+
{ open && isSelected && (
7980
<Popover
80-
anchor={ buttonRef.current }
81+
anchor={ anchorRef.current }
8182
placement="bottom-start"
8283
onClose={ () => setOpen( false ) }
8384
focusOnMount={ false }
85+
offset={ 8 }
8486
>
8587
<div ref={ linkWrapRef } style={ { width: 360 } }>
8688
<LinkControl

0 commit comments

Comments
 (0)