Skip to content

Commit

Permalink
Check whether a button is actually an M3CButton before assuming so.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 644396761
  • Loading branch information
jpsachse authored and material-automation committed Jun 18, 2024
1 parent 04a7740 commit 1c85f89
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ - (void)layoutHorizontalButtons:(NSArray<UIButton *> *)buttons actionSize:(CGSiz
}
buttonOrigin.y = actionsInsets.top;
for (UIButton *button in buttons) {
if (self.isM3CButtonEnabled) {
if (self.isM3CButtonEnabled && [button isKindOfClass:M3CButton.class]) {
M3CButton *m3cButton = (M3CButton *)button;
if (m3cButton.textCanWrap) {
m3cButton.textCanWrap = false;
Expand Down Expand Up @@ -1126,7 +1126,7 @@ - (void)layoutVerticalButtons:(NSArray<UIButton *> *)buttons {
buttonCenter.y = buttonOrigin.y;
for (NSUInteger index = 0; index < buttons.count; ++index) {
UIButton *button = buttons[index];
if (self.isM3CButtonEnabled) {
if (self.isM3CButtonEnabled && [button isKindOfClass:M3CButton.class]) {
M3CButton *m3cButton = (M3CButton *)button;
m3cButton.textCanWrap = YES;
self.titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
Expand Down

0 comments on commit 1c85f89

Please sign in to comment.