Skip to content

Commit 6be776f

Browse files
committed
minor fix
- do nothing if block style is already "Default" - add focus on save/update buttons - fix save/update buttons styles
1 parent b52941d commit 6be776f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/components/block-styles-control/editor.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@
7979
}
8080

8181
.ugb-block-styles-controls__popover {
82-
.ugb-block-styles-controls__list .components-button:focus:not(:disabled) {
83-
box-shadow: none;
84-
outline: 1px solid #e0e0e0;
85-
}
8682
.components-button {
8783
width: 100%;
8884
position: relative;
8985

9086
&.ugb-block-styles-controls__selected {
91-
outline: 2px solid var(--stk-skin-dark) !important;
87+
outline: 1px solid var(--stk-skin-dark) !important;
88+
}
89+
90+
&:focus:not(:disabled) {
91+
box-shadow: 0 0 0 2px var(--stk-skin-dark);
9292
}
9393

9494
.dashicons-lock {

src/components/block-styles-control/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export const BlockStylesControl = props => {
4949

5050
const prevBlockStyleRef = useRef( null )
5151
const buttonRef = useRef( null )
52-
const popoverOnCloseTimeout = useRef( null )
53-
const popoverOnCloseRef = useRef( false )
5452
const panelBodyRef = useRef( null )
5553

5654
// Reset openProNotice when the popover is closed
@@ -126,6 +124,11 @@ export const BlockStylesControl = props => {
126124
}, [ blockStyle ] )
127125

128126
const onSelectDefaultBlockStyle = () => {
127+
// Do nothing if block style is already "Default"
128+
if ( ! blockStyle ) {
129+
return
130+
}
131+
129132
setAttributes( { ...defaultBlockAttributes, modifiedBlockStyle: false } )
130133
}
131134

@@ -196,13 +199,7 @@ export const BlockStylesControl = props => {
196199
className="ugb-button-icon-control__popover ugb-block-styles-controls__popover"
197200
focusOnMount={ false }
198201
onEscape={ () => setOpenPopover( false ) }
199-
onClose={ () => {
200-
setOpenPopover( false )
201-
// This prevents the popover from reopening if the button was clicked
202-
popoverOnCloseRef.current = true
203-
clearTimeout( popoverOnCloseTimeout.current )
204-
popoverOnCloseTimeout.current = setTimeout( () => popoverOnCloseRef.current = false, 100 )
205-
} }
202+
onClose={ () => setOpenPopover( false ) }
206203
anchor={ buttonRef.current }
207204
offset={ 8 }
208205
placement="left-start"
@@ -218,6 +215,7 @@ export const BlockStylesControl = props => {
218215
<Button
219216
onClick={ () => onSelectDefaultBlockStyle() }
220217
className={ ! blockStyle ? 'ugb-block-styles-controls__selected' : '' }
218+
tabIndex={ 0 }
221219
>
222220
{ ! blockStyle && <span className="ugb-block-styles-controls__selected-icon"> <Dashicon icon="saved" /> </span> }
223221
<span className="ugb-block-styles-controls__label">{ __( 'Default', i18n ) }</span>
@@ -228,6 +226,7 @@ export const BlockStylesControl = props => {
228226
<Button
229227
onClick={ () => onSelectBlockStyle( option.slug ) }
230228
className={ blockStyle === option.slug ? 'ugb-block-styles-controls__selected' : '' }
229+
tabIndex={ 0 }
231230
>
232231
{ blockStyle === option.slug && <span className="ugb-block-styles-controls__selected-icon"> <Dashicon icon="saved" /> </span> }
233232
<span className="ugb-block-styles-controls__label">
@@ -287,7 +286,7 @@ const SaveUpdateButtons = props => {
287286
}
288287

289288
return ( <>
290-
<Flex style={ { marginTop: '24px' } }>
289+
<Flex style={ { marginTop: '24px' } } direction="column" align="flex-end">
291290
<FlexItem>
292291
<UpdateButton
293292
blockStyle={ blockStyle }

0 commit comments

Comments
 (0)