-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[a11y] : set isFocused will update isFocusable to true #170935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
376de89
to
5408de2
Compare
ed7ed86
to
e823d05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to add a migration guide
_flags = _flags.copyWith(isFocused: value); | ||
bool? get isFocused => _flags.isFocusable ? _flags.isFocused : null; | ||
set isFocused(bool? value) { | ||
if (value != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is null, should this reset isFocusable? I looked at other property looks like they just pass the null to the flags, not sure if those make sense neither
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this to reset isFocusable to false if this is null, i think it makes more sense to me.
@@ -955,7 +955,7 @@ class RenderCustomPaint extends RenderProxyBox { | |||
config.isFocusable = properties.focusable!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should attempt to migrate this, the focusable in SemanticsProperty should be deprecated as well
PR to add breaking changes doc flutter/website#12159 |
} | ||
if (properties.focused != null) { | ||
config.isFocused = properties.focused!; | ||
if (properties.focusable != null ||properties.focused != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not formatted correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this for backward compatibility? why do we need to check for focusable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was for backward compatibility but yeah this should be updated
previously, properties.focused== null
means the properties don't have a meaningful value for focused
, now it explicitly means this semantics node is not focusable. So the config.focused
should be updated even if properties.focused
is null. but if we always update config.focused
, the _hasBeenAnnotated
in semanticsNode might be messed up and the tree structure will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -726,7 +726,7 @@ class _FocusState extends State<Focus> { | |||
? focusNode.requestFocus | |||
: null, | |||
focusable: _couldRequestFocus, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should remove any invocation to the deprecated property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like Semantics(focusable) is not deprecated. is there a reason we want to keep it around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i should remove this, my mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Deprecated( | ||
'Setting isFocused automatically set this to true. ' | ||
'This feature was deprecated after v3.34.0-0.0.pre.', | ||
) | ||
set isFocusable(bool value) { | ||
_flags = _flags.copyWith(isFocusable: value); | ||
_hasBeenAnnotated = true; | ||
} | ||
|
||
/// Whether the owning [RenderObject] currently holds the input focus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the doc around isFocused should mention null if this is not focusable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and elsewhere
@@ -3815,11 +3815,12 @@ void main() { | |||
await tester.pumpWidget(buildDropdownMenu(requestFocusOnTap: true)); | |||
|
|||
expect( | |||
tester.getSemantics(find.byType(TextField)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7a2c556
to
46f29bb
Compare
46f29bb
to
790c6c1
Compare
This PR is failing dozens of google 3 tests , some because textfield now have isFocusable flags, some because of other reasons, i'm still fixing google 3 tests. |
isfocusable changes revert inkwell changes isfocusable changes Update ink_well.dart Update semantics.dart lint Update shortcuts_test.dart fix tests test resolve comments fix tests Update semantics.dart fix tests resolve comments Update semantics.dart Update packages/flutter/lib/src/semantics/semantics.dart mark Deprecated Update semantics_test.dart update more tests fix tests updates lint Update semantics.dart Update semantics.dart Update semantics.dart Co-Authored-By: chunhtai <47866232+chunhtai@users.noreply.github.com>
e63ff63
to
9341156
Compare
the isFocused and isFocusable flags should be more consistent,
this is also to prepare for #170696 ,
So all EditableText and TextField widgets will have isFocusable flag set to true now. (because they set isFocused).
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.