Skip to content

Commit cfb3250

Browse files
gumacahinbfintal
andauthored
fix (toolbar): allow only one toolbar pop up (#2132). fixes #2130
* Fix #2130 * minor tweaks * changed variable name Co-authored-by: Benjamin Intal <[email protected]>
1 parent 2249c29 commit cfb3250

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/format-types/highlight/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ const HighlightButton = props => {
119119

120120
// Close the window if the user clicks outside.
121121
const clickOutsideListener = useCallback( event => {
122-
if ( isOpen ) {
123-
if ( ! isElementDescendant( popoverEl.current, event.target ) && ! event.target.closest( '.components-popover' ) ) {
124-
setIsOpen( false )
125-
}
122+
const isOutside = ! isElementDescendant( popoverEl.current, event.target )
123+
const isToolbarButton = event.target.closest( '.stk-components-toolbar__highlight' )
124+
if ( isOpen && isOutside && ! isToolbarButton ) {
125+
setIsOpen( false )
126126
}
127127
} )
128128

@@ -175,7 +175,7 @@ const HighlightButton = props => {
175175
<Toolbar className="stackable-components-toolbar">
176176
<Button
177177
label={ __( 'Color & Highlight', i18n ) }
178-
className="components-toolbar__control stk-toolbar-button"
178+
className="components-toolbar__control stk-toolbar-button stk-components-toolbar__highlight"
179179
icon="editor-textcolor"
180180
aria-haspopup="true"
181181
tooltip={ __( 'Color & Highlight', i18n ) }

0 commit comments

Comments
 (0)