Skip to content

Commit 6b4b029

Browse files
Nobodymaterial-automation
authored andcommitted
[Manage People/Links] Rotation UI Bug Fix
This change is a slight alteration to the change introduced in cl/347036858 this moves the added code to the bottom of the method so as to not interfere with the recursive call. BEGIN_PUBLIC Made a slight change to move adding `presentingViewYOffset' to `_contentHeightSurplus` to the end of the method. This was added in a previous change but didn't take into account the possibility of an infinite recursive loop. This movement should prevent that while also updating `_contentHeightSurplus` to the proper value. This should also fix the bug brought up in b/176122058 END_PUBLIC PiperOrigin-RevId: 351455638
1 parent 11e4afa commit 6b4b029

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

components/NavigationDrawer/src/private/MDCBottomDrawerContainerViewController.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#import "MDCBottomDrawerContainerViewController.h"
1616

1717
#import "MDCBottomDrawerHeader.h"
18+
#import "MDCBottomDrawerState.h"
1819
#import "MDCBottomDrawerContainerViewControllerDelegate.h"
19-
#import "MDCBottomDrawerHeaderMask.h"
2020
#import "MDCBottomDrawerShadowedView.h"
21+
#import "MaterialShadowElevations.h"
22+
#import "MaterialShadowLayer.h"
2123
#import "MaterialApplication.h"
2224
#import "MaterialMath.h"
2325
#import "MaterialUIMetrics.h"
@@ -1099,11 +1101,6 @@ - (void)cacheLayoutCalculationsWithAddedContentHeight:(CGFloat)addedContentHeigh
10991101

11001102
CGFloat scrollingDistance = _contentHeaderTopInset + totalHeight;
11011103
_contentHeightSurplus = scrollingDistance - containerHeight;
1102-
// readded `presentingViewYOffset` because offset is cancelled out
1103-
// by being included in both the `scrollingDistance` and `containerHeight`.
1104-
// Because `containerHeight` is used in independent calculations
1105-
// we can't remove the offset from there.
1106-
_contentHeightSurplus += self.presentingViewYOffset;
11071104
if ([self shouldPresentFullScreen]) {
11081105
self.drawerState = MDCBottomDrawerStateFullScreen;
11091106
} else if (_contentHeightSurplus <= 0) {
@@ -1116,6 +1113,13 @@ - (void)cacheLayoutCalculationsWithAddedContentHeight:(CGFloat)addedContentHeigh
11161113
CGFloat addedContentheight = _contentHeaderTopInset - _contentHeightSurplus;
11171114
[self cacheLayoutCalculationsWithAddedContentHeight:addedContentheight];
11181115
}
1116+
// Readded `presentingViewYOffset` because offset is cancelled out
1117+
// by being included in both the `scrollingDistance` and `containerHeight`.
1118+
// Because `containerHeight` is used in independent calculations
1119+
// we can't remove the offset from there.
1120+
// This y-offset should be readded at the end of this method, this is to prevent it from being
1121+
// included in the recursive call in the conditional above.
1122+
_contentHeightSurplus += self.presentingViewYOffset;
11191123
}
11201124

11211125
- (CGFloat)transitionPercentageForContentOffset:(CGPoint)contentOffset

components/NavigationDrawer/tests/unit/MDCNavigationDrawerTest.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,6 @@ - (void)testContentHeightSurplusIsAddingYOffset {
294294
self.navigationDrawer.headerViewController.preferredContentSize = CGSizeMake(100, 200);
295295
self.navigationDrawer.contentViewController.preferredContentSize = CGSizeMake(100, 200);
296296
[self.navigationDrawer.presentationController presentationTransitionWillBegin];
297-
// This will be used to assert the `contentHeightSurplus` The height surplus is calculated by
298-
// adding the content height and the header height. We then add the `presentingViewYOffset`.
299-
// The offset is calculated by subtracting the frame height with the presenting bounds height.
300-
// The presenting view bounds here is 0 and the content and header height get cancelled out in
301-
// the surplus calculation. So the surplus ends up being the frame height
302-
CGFloat frameHeight = CGRectGetHeight(self.navigationDrawer.view.frame);
303297

304298
// When
305299
self.navigationDrawer.maximumDrawerHeight = 0;
@@ -314,7 +308,7 @@ - (void)testContentHeightSurplusIsAddingYOffset {
314308
XCTAssertEqual(presentationController.bottomDrawerContainerViewController.maximumDrawerHeight,
315309
0);
316310
XCTAssertEqual(presentationController.bottomDrawerContainerViewController.contentHeightSurplus,
317-
frameHeight);
311+
880);
318312
} else {
319313
XCTFail(@"The presentation controller should be class of kind "
320314
@"MDCBottomDrawerPresentationController but is %@",

0 commit comments

Comments
 (0)