Unverified Commit c8ff617f authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

Text field border radius bug fix (#24414)

* Fix radius glitch by carrying over border when lerping outline borders

* Test that border doesn't change

* Regression comment
parent 2d87b823
......@@ -195,6 +195,7 @@ class UnderlineInputBorder extends InputBorder {
if (a is UnderlineInputBorder) {
return UnderlineInputBorder(
borderSide: BorderSide.lerp(a.borderSide, borderSide, t),
borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t),
);
}
return super.lerpFrom(a, t);
......@@ -205,6 +206,7 @@ class UnderlineInputBorder extends InputBorder {
if (b is UnderlineInputBorder) {
return UnderlineInputBorder(
borderSide: BorderSide.lerp(borderSide, b.borderSide, t),
borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t),
);
}
return super.lerpTo(b, t);
......
......@@ -1898,10 +1898,10 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
helperError: helperError,
counter: counter,
container: container,
),
textDirection: textDirection,
textBaseline: textBaseline,
isFocused: isFocused,
),
textDirection: textDirection,
textBaseline: textBaseline,
isFocused: isFocused,
);
}
}
......
......@@ -77,6 +77,14 @@ BorderSide getBorderSide(WidgetTester tester) {
return getBorder(tester)?.borderSide;
}
BorderRadius getBorderRadius(WidgetTester tester) {
final InputBorder border = getBorder(tester);
if (border is UnderlineInputBorder) {
return border.borderRadius;
}
return null;
}
double getBorderWeight(WidgetTester tester) => getBorderSide(tester)?.width;
Color getBorderColor(WidgetTester tester) => getBorderSide(tester)?.color;
......@@ -1931,6 +1939,44 @@ void main() {
expect(getBorder(tester), disabledBorder);
});
testWidgets('OutlineInputBorder radius carries over when lerping', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/23982
const Key key = Key('textField');
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: TextField(
key: key,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
border: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue, width: 2.0),
borderRadius: BorderRadius.zero,
),
),
),
),
),
),
);
// TextField has the given border
expect(getBorderRadius(tester), BorderRadius.zero);
// Focusing does not change the border
await tester.tap(find.byKey(key));
await tester.pump();
expect(getBorderRadius(tester), BorderRadius.zero);
await tester.pump(const Duration(milliseconds: 100));
expect(getBorderRadius(tester), BorderRadius.zero);
await tester.pumpAndSettle();
expect(getBorderRadius(tester), BorderRadius.zero);
});
test('InputBorder equality', () {
// OutlineInputBorder's equality is defined by the borderRadius, borderSide, & gapPadding
const OutlineInputBorder outlineInputBorder = OutlineInputBorder(
......@@ -1971,5 +2017,4 @@ void main() {
expect(underlineInputBorder.hashCode, const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)).hashCode);
expect(underlineInputBorder.hashCode, isNot(const UnderlineInputBorder().hashCode));
});
}
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