Unverified Commit 4c7f7463 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

TextField intrinsic height layout bug (#66291)

Fixes a bug when TextField is wrapped in IntrinsicHeight and visual density is below standard.
parent 3907e490
...@@ -1261,10 +1261,11 @@ class _RenderDecoration extends RenderBox { ...@@ -1261,10 +1261,11 @@ class _RenderDecoration extends RenderBox {
+ (label == null ? 0.0 : decoration.floatingLabelHeight) + (label == null ? 0.0 : decoration.floatingLabelHeight)
+ _lineHeight(width, <RenderBox>[prefix, input, suffix]) + _lineHeight(width, <RenderBox>[prefix, input, suffix])
+ subtextHeight + subtextHeight
+ contentPadding.bottom; + contentPadding.bottom
+ densityOffset.dy;
final double minContainerHeight = decoration.isDense || expands final double minContainerHeight = decoration.isDense || expands
? 0.0 ? 0.0
: kMinInteractiveDimension + densityOffset.dy; : kMinInteractiveDimension;
return math.max(containerHeight, minContainerHeight); return math.max(containerHeight, minContainerHeight);
} }
......
...@@ -4311,4 +4311,44 @@ void main() { ...@@ -4311,4 +4311,44 @@ void main() {
expect(textTop, greaterThan(textFieldTop)); expect(textTop, greaterThan(textFieldTop));
expect(textTop, lessThan(textFieldBottom)); expect(textTop, lessThan(textFieldBottom));
}); });
testWidgets('visual density is included in the intrinsic height calculation', (WidgetTester tester) async {
final UniqueKey key = UniqueKey();
final UniqueKey intrinsicHeightKey = UniqueKey();
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(visualDensity: VisualDensity.compact),
child: Center(
child: Row(
children: <Widget>[
SizedBox(
width: 35.0,
child: TextField(
key: key,
),
),
SizedBox(
width: 35.0,
child: IntrinsicHeight(
child: TextField(
key: intrinsicHeightKey,
),
),
),
],
),
),
);
},
),
),
));
final double height = tester.getSize(find.byKey(key)).height;
final double intrinsicHeight = tester.getSize(find.byKey(intrinsicHeightKey)).height;
expect(intrinsicHeight, equals(height));
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment