Skip to content

Commit

Permalink
Small refactor, fix on translation
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Jun 23, 2023
1 parent 15fe971 commit 3d083f2
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions packages/block-editor/src/hooks/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,14 @@ function BehaviorsControl( {
? __( 'The lightbox behavior is disabled for linked images.' )
: '';

const value = () => {
if ( blockBehaviors === undefined ) {
return 'default';
}
if ( behaviors?.lightbox.enabled ) {
return 'lightbox';
}
return '';
};
let behaviorsValue = '';

const shouldShowAnimationSelector =
value() !== 'default' && behaviors?.lightbox.enabled;
if ( blockBehaviors === undefined ) {
behaviorsValue = 'default';
}
if ( behaviors?.lightbox.enabled ) {
behaviorsValue = 'lightbox';
}

return (
<InspectorControls group="advanced">
Expand All @@ -96,15 +92,15 @@ function BehaviorsControl( {
<SelectControl
label={ __( 'Behaviors' ) }
// At the moment we are only supporting one behavior (Lightbox)
value={ value() }
value={ behaviorsValue }
options={ options }
onChange={ onChangeBehavior }
hideCancelButton={ true }
help={ helpText }
size="__unstable-large"
disabled={ disabled }
/>
{ shouldShowAnimationSelector && (
{ behaviorsValue === 'lightbox' && (
<SelectControl
label={ __( 'Animation' ) }
// At the moment we are only supporting one behavior (Lightbox)
Expand All @@ -118,7 +114,10 @@ function BehaviorsControl( {
value: 'zoom',
label: __( 'Zoom' ),
},
{ value: 'fade', label: 'Fade' },
{
value: 'fade',
label: __( 'Fade' ),
},
] }
onChange={ onChangeAnimation }
hideCancelButton={ false }
Expand Down

0 comments on commit 3d083f2

Please sign in to comment.