Skip to content

Commit

Permalink
[Tabs] Vertically hug content in sizeThatFits: (#7777)
Browse files Browse the repository at this point in the history
To ensure that TabBarView works correctly with the Flexible Header, it should
"hug" its content vertically when interrogated for a fit size. The previous
behavior may have resulted in a tab bar that was too tall (or too short).

Closes #7769
  • Loading branch information
Robert Moore committed Jul 2, 2019
1 parent a19b730 commit 012c11d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/Tabs/src/TabBarView/MDCTabBarView.m
Expand Up @@ -559,7 +559,7 @@ - (CGSize)intrinsicContentSizeForScrollableLayout {

- (CGSize)sizeThatFits:(CGSize)size {
CGSize intrinsicSize = self.intrinsicContentSize;
return CGSizeMake(MAX(intrinsicSize.width, size.width), MAX(intrinsicSize.height, size.height));
return CGSizeMake(MAX(intrinsicSize.width, size.width), intrinsicSize.height);
}

#pragma mark - Helpers
Expand Down
4 changes: 2 additions & 2 deletions components/Tabs/tests/unit/TabBarView/MDCTabBarViewTests.m
Expand Up @@ -653,7 +653,7 @@ - (void)testSizeThatFitsExpandsToFitContent {
XCTAssertEqualWithAccuracy(size.height, kMinHeight, 0.001);
}

- (void)testSizeThatFitsDoesntShrinkToFitContent {
- (void)testSizeThatFitsShrinksToFitContentVerticallyButNotHorizontally {
// Given
self.tabBarView.items = @[ self.itemA ];
CGSize intrinsicSize = self.tabBarView.intrinsicContentSize;
Expand All @@ -664,7 +664,7 @@ - (void)testSizeThatFitsDoesntShrinkToFitContent {

// Then
XCTAssertEqualWithAccuracy(size.width, biggerSize.width, 0.001);
XCTAssertEqualWithAccuracy(size.height, biggerSize.height, 0.001);
XCTAssertEqualWithAccuracy(size.height, intrinsicSize.height, 0.001);
}

@end

0 comments on commit 012c11d

Please sign in to comment.