Skip to content

Commit

Permalink
[TextControls] consider floating label min Y in - accessibilityPath
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 337120665
  • Loading branch information
andrewoverton authored and material-automation committed Oct 14, 2020
1 parent 364b062 commit b8d8690
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ @implementation MDCTextControlTextAreaConfiguratorExample (CatalogByConvention)
+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Text Controls", kExampleTitle ],
@"description" : @"Text areas let users enter and edit text.",
@"primaryDemo" : @NO,
@"presentable" : @YES,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ @implementation MDCTextControlTextFieldConfiguratorExample (CatalogByConvention)
+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Text Controls", kExampleTitle ],
@"description" : @"Text fields let users enter and edit text.",
@"primaryDemo" : @YES,
@"presentable" : @YES,
};
Expand Down
18 changes: 14 additions & 4 deletions components/TextControls/src/BaseTextFields/MDCBaseTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,22 @@ - (NSString *)accessibilityLabel {
}

- (UIBezierPath *)accessibilityPath {
return [UIBezierPath bezierPathWithRect:self.accessibilityFrame];
}

- (CGRect)accessibilityFrame {
if (self.window) {
CGRect frameInScreenCoordinates = [self convertRect:self.bounds
toCoordinateSpace:self.window.screen.coordinateSpace];
return [UIBezierPath bezierPathWithRect:frameInScreenCoordinates];
CGRect bounds = self.bounds;
CGFloat boundsMinY = CGRectGetMinY(bounds);
CGFloat floatingLabelMinY = CGRectGetMinY(self.layout.labelFrameFloating);
if (floatingLabelMinY < boundsMinY) {
CGFloat difference = boundsMinY - floatingLabelMinY;
bounds.origin.y = boundsMinY - difference;
bounds.size.height = bounds.size.height + difference;
}
return [self convertRect:bounds toCoordinateSpace:self.window.screen.coordinateSpace];
} else {
return [super accessibilityPath];
return [super accessibilityFrame];
}
}

Expand Down

0 comments on commit b8d8690

Please sign in to comment.