@@ -56,6 +56,23 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
5656 // Block behaviors take precedence over theme behaviors.
5757 const behaviors = merge ( themeBehaviors , blockBehaviors || { } ) ;
5858
59+ const noBehaviorsOption = {
60+ value : '' ,
61+ label : __ ( 'No behaviors' ) ,
62+ } ;
63+
64+ const behaviorsOptions = Object . entries ( settings )
65+ . filter ( ( [ , behaviorValue ] ) => behaviorValue ) // Filter out behaviors that are disabled.
66+ . map ( ( [ behaviorName ] ) => ( {
67+ value : behaviorName ,
68+ label :
69+ // Capitalize the first letter of the behavior name.
70+ behaviorName [ 0 ] . toUpperCase ( ) +
71+ behaviorName . slice ( 1 ) . toLowerCase ( ) ,
72+ } ) ) ;
73+
74+ const options = [ noBehaviorsOption , ...behaviorsOptions ] ;
75+
5976 return (
6077 < >
6178 < BlockEdit { ...props } />
@@ -65,19 +82,7 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
6582 label = { __ ( 'Behaviors' ) }
6683 // At the moment we are only supporting one behavior (Lightbox)
6784 value = { behaviors ?. lightbox ? 'lightbox' : '' }
68- options = { Object . entries ( settings )
69- . filter ( ( [ , behaviorValue ] ) => behaviorValue ) // Filter out behaviors that are disabled.
70- . map ( ( [ behaviorName ] ) => ( {
71- value : behaviorName ,
72- label :
73- // Capitalize the first letter of the behavior name.
74- behaviorName [ 0 ] . toUpperCase ( ) +
75- behaviorName . slice ( 1 ) . toLowerCase ( ) ,
76- } ) )
77- . concat ( {
78- value : '' ,
79- label : __ ( 'No behaviors' ) ,
80- } ) }
85+ options = { options }
8186 onChange = { ( nextValue ) => {
8287 // If the user selects something, it means that they want to
8388 // change the default value (true) so we save it in the attributes.
0 commit comments