Unverified Commit 24e7a0be authored by yim's avatar yim Committed by GitHub

Don't change the height of the Textfield's labelStyle when it focused. (#141943)

Fixes #141448
parent be031cb9
...@@ -2123,9 +2123,9 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat ...@@ -2123,9 +2123,9 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
return themeData.textTheme.titleMedium! return themeData.textTheme.titleMedium!
.merge(widget.baseStyle) .merge(widget.baseStyle)
.copyWith(height: 1)
.merge(defaultTextStyle) .merge(defaultTextStyle)
.merge(style); .merge(style)
.copyWith(height: 1);
} }
TextStyle _getHelperStyle(ThemeData themeData, InputDecorationTheme defaults) { TextStyle _getHelperStyle(ThemeData themeData, InputDecorationTheme defaults) {
......
...@@ -7022,4 +7022,29 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular ...@@ -7022,4 +7022,29 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular
reason: 'clamp is expected', reason: 'clamp is expected',
); );
}); });
testWidgets('Ensure the height of labelStyle remains unchanged when TextField is focused.', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Material(
child: TextField(
focusNode: focusNode,
decoration: const InputDecoration(
labelText: 'label',
),
),
),
),
);
final TextStyle beforeStyle = getLabelStyle(tester);
// Focused.
focusNode.requestFocus();
await tester.pumpAndSettle();
expect(getLabelStyle(tester).height, beforeStyle.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