Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix: Button button value to be stored as a value + unit
  • Loading branch information
enejb committed Jul 14, 2021
commit ee4e649ff77125d18bb47d1e44bfd2af8dc4677b
19 changes: 15 additions & 4 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class ButtonEdit extends Component {
...style,
border: {
...style?.border,
radius: newRadius,
radius: `${ newRadius }px`, // Store the value with the px value so that it works as expected.
},
};

Expand Down Expand Up @@ -368,6 +368,16 @@ class ButtonEdit extends Component {
}
}

getBorderRadiusValue( borderRadius, defaultBorderRadius ) {
// Return an integer value for the border Radius.
// Since that is what the we expect that value to be.
if ( Number.isInteger( parseInt( borderRadius ) ) ) {
return parseInt( borderRadius );
}

return defaultBorderRadius;
}

render() {
const {
attributes,
Expand Down Expand Up @@ -395,10 +405,11 @@ class ButtonEdit extends Component {
}

const borderRadius = buttonStyle?.border?.radius;
const borderRadiusValue = this.getBorderRadiusValue(
borderRadius,
styles.defaultButton.borderRadius
);

const borderRadiusValue = Number.isInteger( borderRadius )
? borderRadius
: styles.defaultButton.borderRadius;
const outlineBorderRadius =
borderRadiusValue > 0
? borderRadiusValue + spacing + borderWidth
Expand Down