Add MediaQueryData.navigationMode and allow controls to be focused when disabled.#54919
Conversation
91781b1 to
dae6393
Compare
dae6393 to
c791b07
Compare
c791b07 to
67d03fd
Compare
There was a problem hiding this comment.
I don't fully understand the changes in this file. If the widget is focused, there's no longer a way to tell from its visuals whether it's enabled or not? Is this in line with material spec?
/cc @HansMuller
There was a problem hiding this comment.
No, there's definitely no Material spec for this.
That's something I think I'll be asking the customer to push for, since this is a use case that probably needs some design work.
There was a problem hiding this comment.
But you can usually tell if it is disabled: all the hints and labels are shown as "disabled", and it acts like a read-only field. Of course, if you don't have any hints or labels, then no, you can't tell.
In order to provide that, we'll have to add a disabledFocusColor or something. Waiting for some more spec guidance before doing that seems like a good idea.
There was a problem hiding this comment.
(side node: I really wish we would have called this property "focusable" instead of "canRequestFocus")
There was a problem hiding this comment.
Yeah, me to. It's already in our "I wish we could make a breaking change for this" issue. I mean, I'm happy to make a breaking change if we think it is important enough, but it would be just a name change.
|
What's the reason to go with the NavigationModality over a new TargetPlatform now? Also, my understanding from the discord discussion with @Hixie was that if we do an inherited widget, widgets that use it should have a flag to allow overriding the inherited behavior, similarly to the various textDirection flags. |
justinmc
left a comment
There was a problem hiding this comment.
LGTM from a TextField point of view.
My reasoning for having this new inherited widget was to provide for a layered design that would avoid complecting the idea of a navigation mode with a target platform. If we did decide to add a new target platform, then this would be one aspect of implementing the default for that platform. That said, I spoke with @Hixie some more, and he said that we need to decide whether this navigation paradigm is an attribute of the platform, an attribute of the design language, or just a mode that we enter when people do any kind of directional navigation. My thought in this PR was to make it be a design decision for the developer: you apply this inherited widget when you design an app (or part of an app) to use directional navigation, making it a conscious design choice, but it could be that we want to make the default sensitive to the platform. In our discussion, he also pointed out that if it's a platform attribute that can be overridden, that the I'm going to talk to the customer and see if they can describe more about their use case, and see if they can get some Material Design guidance for us. |
67d03fd to
d54b948
Compare
522cca0 to
21cc0d4
Compare
|
After speaking with the customer, it seems that this is a design choice that they would like to make on multiple platforms, even ones where directional isn't the primary navigation method. I need to get more details from the Material Design team still about whether or not we need an entirely new mode for controls that can be focused while disabled or not, how that modifies controls like text fields and sliders, and how it affects semantics of those widgets. In the meantime, in order to allow the customer to make progress, I'd like to continue with this PR. I've moved the |
21cc0d4 to
3767961
Compare
|
One thing that might make sense is to move the |
3767961 to
2b2658a
Compare
goderbauer
left a comment
There was a problem hiding this comment.
The implementation LGTM from a technical point of view. I am unsure if we are given the material widgets the right visual treatment in this new mode when they are disabled. Did you get some guidance from the Material team on that? Changing this later may be an annoying breaking change (for customers that use screenshot tests).
There was a problem hiding this comment.
material cannot be imported from within material.
There was a problem hiding this comment.
Stupid IntelliJ! I've tried turning it off a bunch of times, but it insists on inserting imports when it shouldn't (I didn't add this import manually).
There was a problem hiding this comment.
nit: Maybe add a one-sentence example describing what you would do differently depending on the mode. I think that would increase the understanding of what this property should be used for.
There was a problem hiding this comment.
Good idea. I added a small paragraph about this.
There was a problem hiding this comment.
update comment to remove reference to NavigationModality?
There was a problem hiding this comment.
Whoops. Fixed.
|
Also: the analyzer is unhappy. |
|
Can you maybe also update the PR description for future archaeologists? I was at first confused when I read about a NavigationModality widget in there and then didn't find it in the code :) |
Update other widgets to remain focused when disabled if navigation mode is NavigationMode.directional.
2b2658a to
4a82c57
Compare
| /// Some behaviors are also affected by this mode. For instance, disabled | ||
| /// controls will retain focus when disabled, and will be able to receive | ||
| /// focus (although they remain disabled) when traversed. | ||
| directional, |
There was a problem hiding this comment.
we should probably mention that this is for TVs.
Description
This adds a new
navigationModeto theMediaQueryDatathat indicates how focusable controls should behave under different navigation modes, currently with two modes:NavigationMode.traditional, andNavigationMode.directional.It may seem like focusing a disabled control is not desirable, but this is useful for user interfaces that use DPAD navigation because if a control gets disabled, losing focus is disruptive to the user, and it is difficult to control where the focus will end up unless it is done explicitly.
Related Issues
Tests
Breaking Change