Skip to content

Commit

Permalink
fix (button group): flex wrap with full width not working in frontend
Browse files Browse the repository at this point in the history
fixes #3135
  • Loading branch information
[email protected] committed May 8, 2024
1 parent 088e5ff commit 7ae311c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/block/button-group/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,16 @@ const Styles = props => {
styleRule="flex"
attrName="buttonFullWidth"
key="buttonFullWidth-save"
valueCallback={ value => {
return value ? '1' : undefined
valueCallback={ ( value, getAttribute ) => {
let basis = '0%' // This is the default value of flex-basis
// If we're wrapping, we need to set flex-basis to auto so
// that it will wrap and go full-width.
if ( getAttribute( 'flexWrap' ) ) {
basis = 'auto'
}
return value ? ( '1 0 ' + basis ) : undefined
} }
dependencies={ [ 'flexWrap' ] }
/>
<BlockCss
{ ...propsToPass }
Expand All @@ -192,9 +199,16 @@ const Styles = props => {
styleRule="flex"
attrName="buttonFullWidth"
key="buttonFullWidth"
valueCallback={ value => {
return value ? '1' : undefined
valueCallback={ ( value, getAttribute ) => {
let basis = '0%' // This is the default value of flex-basis
// If we're wrapping, we need to set flex-basis to auto so
// that it will wrap and go full-width.
if ( getAttribute( 'flexWrap' ) ) {
basis = 'auto'
}
return value ? ( '1 0 ' + basis ) : undefined
} }
dependencies={ [ 'flexWrap' ] }
/>
</>
)
Expand Down

0 comments on commit 7ae311c

Please sign in to comment.