TextField intrinsic height layout bug (#66291)

Fixes a bug when TextField is wrapped in IntrinsicHeight and visual density is below standard.
This commit is contained in:
Justin McCandless 2020-09-21 15:29:00 -07:00 committed by GitHub
parent 3907e490a0
commit 4c7f746374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 2 deletions

View file

@ -1261,10 +1261,11 @@ class _RenderDecoration extends RenderBox {
+ (label == null ? 0.0 : decoration.floatingLabelHeight)
+ _lineHeight(width, <RenderBox>[prefix, input, suffix])
+ subtextHeight
+ contentPadding.bottom;
+ contentPadding.bottom
+ densityOffset.dy;
final double minContainerHeight = decoration.isDense || expands
? 0.0
: kMinInteractiveDimension + densityOffset.dy;
: kMinInteractiveDimension;
return math.max(containerHeight, minContainerHeight);
}

View file

@ -4311,4 +4311,44 @@ void main() {
expect(textTop, greaterThan(textFieldTop));
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));
});
}