Skip to content

Commit

Permalink
Update -sizeBasedOnLabel to return a size that is consistent with -si…
Browse files Browse the repository at this point in the history
…zeThatFits:.

Change -sizeBasedOnLabel to apply ceil() to the width of the label. Without this change, the width will differ slightly based on the textCanWrap property. This avoids differences that was resulting in an infinite layout loop in MDCAlertController.

PiperOrigin-RevId: 662959086
  • Loading branch information
Nobody authored and material-automation committed Aug 14, 2024
1 parent 142d22b commit b1164e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/M3CButton/src/M3CButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ - (CGSize)sizeBasedOnLabel {
CGSize titleLabelSize = self.titleLabel.intrinsicContentSize;
self.titleLabel.preferredMaxLayoutWidth = textWidth;
return CGSizeMake(
titleLabelSize.width + self.contentEdgeInsets.left + self.contentEdgeInsets.right +
ceil(titleLabelSize.width) + self.contentEdgeInsets.left + self.contentEdgeInsets.right +
self.imageView.frame.size.width,
titleLabelSize.height + self.contentEdgeInsets.top + self.contentEdgeInsets.bottom);
}
Expand Down

0 comments on commit b1164e6

Please sign in to comment.