[M3] TextField
"hovered" has priority over "focused". Filled "focused" and all "focused" error border is 1 dp, should be 2dp.
#113329
Labels
a: text input
Entering text in a text field or keyboard related problems
f: material design
flutter/packages/flutter/material repository.
found in release: 3.3
Found to occur in 3.3
found in release: 3.4
Found to occur in 3.4
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
r: fixed
Issue is closed as already fixed in a newer version
Uh oh!
There was an error while loading. Please reload this page.
Background
This issue is filed based on my comment here #110878 (comment) and reply here #110878 (comment) by @HansMuller to post my audit findings of the M3 TextField decoration.
Issue Description
In master channel (v. 3.5.0-6.0.pre.19) when enabling Material 3 and using a state of "focused" + "hovered". A state you often end up with on desktop when you move the cursor to a text field and focus it, since it will effectively be both focused and hovered then if cursor remains on it. In such a scenario the M3 TextField will get partially "focused", but mostly "hovered" visual design.
The M3 guide does not explicitly say what the result should be since the combination is not included in spec, but it looks like an oversight and not right. Especially considering that a
TextField
that is both "focused" and "hovered", now suddenly looks less prominent than aTextField
that is only "focused", this is probably not intended.It is here assumed implicitly from state presentation order in the M3 guide, that if both "Focused" and "Hovered" states are present, that "Focused" should have priority. This would look better and be consistent with past M2 behavior. Currently the M3
TextField
behaves a bit unexpectedly since it changes its look if you have mouse clicked on it with desktop, to focus it, it is then also "hovered" since your cursor is on it. In current M3InputDecorator
it then gets the "hovered" state, since it has precedence over "focused" in current code. Then if you move the cursor away from theTextfield
it remains "Focused", as it should, but is no longer "Hovered", the style of the field will then change. It probably should not. Often you just move the mouse course away from the field since it might be in the way of the input caret and text, you do not expect the style of the input field to change when you do so.When using filled input border, the focused input border is 1dp, same for focused error border with both M3 border types. Based on web published M3 guide and spec, focused filled input border and focused error borders should be 2dp (https://m3.material.io/components/text-fields/specs).
Actual and Expected Results
Filled Underline Border
Unfilled Outlined Border
Summary of Issues and Solution Proposal
BorderSide 2dp
The

BorderSide
should be 2dp and not 1dp for focused border side, also in filled TextField and for focused error state with both border types, at least based on M3 web specification. This is missing ininput_decorator.dart
:Above the
BorderSide.width: 2.0
for "focused" state is also missing inside "error" state for bothactiveIndicatorBorder
andoutlineBorder
Order of MaterialState Evaluation
In M3
InputDecorator
, wheneverstates.contains
"focused" and "hovered" is used,contains
"focused" should be evaluated before "hovered". This will give "focused" state precedence over "hovered", like it should be and resolve the current odd "focused+hovered" state. Currently we have this ininput_decorator.dart
:The order matters. The above is only one example, the order is the same wherever
focused
andhovered
states are evaluated.Demo Application
A simple demo application using the M3 spec baseline
ColorScheme
that can show underlineTextField
and outlineTextField
and errors states is supplied. It can also demonstrate the issues in dark mode, they were not shown above, but they are equivalent:Reproduction Sample
The demo code for the sample app can be found in GIST here, and is also supplied below.
To actually see the wrong results, manual testing on a desktop or web build is required.
Code sample
Used Flutter Version
Flutter doctor
The text was updated successfully, but these errors were encountered: