Skip to content

Commit

Permalink
RN: Button Block set the width to fixed when width is set (#29360)
Browse files Browse the repository at this point in the history
* RN: Button Block set the width to fixed when width is set

* Remove padding from buttons on android
  • Loading branch information
enejb authored Mar 24, 2021
1 parent 0c14e0b commit aad0052
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class ButtonEdit extends Component {

const backgroundColor = this.getBackgroundColor();
const textColor = this.getTextColor();
const isFixedWidth = !! width;

return (
<View onLayout={ this.onLayout }>
Expand Down Expand Up @@ -426,6 +427,12 @@ class ButtonEdit extends Component {
onChange={ this.onChangeText }
style={ {
...richTextStyle.richText,
paddingLeft: isFixedWidth
? 0
: richTextStyle.richText.paddingLeft,
paddingRight: isFixedWidth
? 0
: richTextStyle.richText.paddingRight,
color: textColor,
} }
textAlign={ align }
Expand All @@ -435,7 +442,7 @@ class ButtonEdit extends Component {
identifier="text"
tagName="p"
minWidth={ minWidth } // The minimum Button size.
maxWidth={ maxWidth } // The width of the screen.
maxWidth={ isFixedWidth ? minWidth : maxWidth } // The width of the screen.
id={ clientId }
isSelected={ isButtonFocused }
withoutInteractiveFormatting
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/button/rich-text.ios.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.richText {
margin: 10px $grid-unit-20;
padding-left: 0;
padding-right: 0;
background-color: transparent;
}

0 comments on commit aad0052

Please sign in to comment.