Unverified Commit a389d177 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

A minor bug fix and comment cleanups for focus (#33135)

This just fixes up some comments for DefaultFocusTraversal, and fixes a minor bug when setting the onKey on a FocusNode on creation before attaching to it.
parent 041755fa
...@@ -659,7 +659,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -659,7 +659,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
@mustCallSuper @mustCallSuper
FocusAttachment attach(BuildContext context, {FocusOnKeyCallback onKey}) { FocusAttachment attach(BuildContext context, {FocusOnKeyCallback onKey}) {
_context = context; _context = context;
_onKey = onKey; _onKey = onKey ?? _onKey;
_attachment = FocusAttachment._(this); _attachment = FocusAttachment._(this);
return _attachment; return _attachment;
} }
......
...@@ -723,7 +723,7 @@ class ReadingOrderTraversalPolicy extends FocusTraversalPolicy with DirectionalF ...@@ -723,7 +723,7 @@ class ReadingOrderTraversalPolicy extends FocusTraversalPolicy with DirectionalF
bool previous(FocusNode currentNode) => _move(currentNode, forward: false); bool previous(FocusNode currentNode) => _move(currentNode, forward: false);
} }
/// A widget that describes an inherited focus policy for focus traversal. /// A widget that describes the inherited focus policy for focus traversal.
/// ///
/// By default, traverses in widget order using /// By default, traverses in widget order using
/// [ReadingOrderFocusTraversalPolicy]. /// [ReadingOrderFocusTraversalPolicy].
...@@ -738,7 +738,7 @@ class ReadingOrderTraversalPolicy extends FocusTraversalPolicy with DirectionalF ...@@ -738,7 +738,7 @@ class ReadingOrderTraversalPolicy extends FocusTraversalPolicy with DirectionalF
/// * [DirectionalFocusTraversalPolicyMixin] a mixin class that implements /// * [DirectionalFocusTraversalPolicyMixin] a mixin class that implements
/// focus traversal in a direction. /// focus traversal in a direction.
class DefaultFocusTraversal extends InheritedWidget { class DefaultFocusTraversal extends InheritedWidget {
/// Creates a FocusTraversal object. /// Creates a [DefaultFocusTraversal] object.
/// ///
/// The [child] argument must not be null. /// The [child] argument must not be null.
const DefaultFocusTraversal({ const DefaultFocusTraversal({
...@@ -763,7 +763,7 @@ class DefaultFocusTraversal extends InheritedWidget { ...@@ -763,7 +763,7 @@ class DefaultFocusTraversal extends InheritedWidget {
/// bottom. /// bottom.
final FocusTraversalPolicy policy; final FocusTraversalPolicy policy;
/// Returns the [DefaultFocusTraversal] that most tightly encloses the given /// Returns the [FocusTraversalPolicy] that most tightly encloses the given
/// [BuildContext]. /// [BuildContext].
/// ///
/// The [context] argument must not be null. /// The [context] argument must not be null.
......
...@@ -441,10 +441,10 @@ void main() { ...@@ -441,10 +441,10 @@ void main() {
final FocusAttachment scope1Attachment = scope1.attach(context, onKey: handleEvent); final FocusAttachment scope1Attachment = scope1.attach(context, onKey: handleEvent);
final FocusScopeNode scope2 = FocusScopeNode(debugLabel: 'Scope 2'); final FocusScopeNode scope2 = FocusScopeNode(debugLabel: 'Scope 2');
final FocusAttachment scope2Attachment = scope2.attach(context, onKey: handleEvent); final FocusAttachment scope2Attachment = scope2.attach(context, onKey: handleEvent);
final FocusNode parent1 = FocusNode(debugLabel: 'Parent 1'); final FocusNode parent1 = FocusNode(debugLabel: 'Parent 1', onKey: handleEvent);
final FocusAttachment parent1Attachment = parent1.attach(context, onKey: handleEvent); final FocusAttachment parent1Attachment = parent1.attach(context);
final FocusNode parent2 = FocusNode(debugLabel: 'Parent 2'); final FocusNode parent2 = FocusNode(debugLabel: 'Parent 2', onKey: handleEvent);
final FocusAttachment parent2Attachment = parent2.attach(context, onKey: handleEvent); final FocusAttachment parent2Attachment = parent2.attach(context);
final FocusNode child1 = FocusNode(debugLabel: 'Child 1'); final FocusNode child1 = FocusNode(debugLabel: 'Child 1');
final FocusAttachment child1Attachment = child1.attach(context, onKey: handleEvent); final FocusAttachment child1Attachment = child1.attach(context, onKey: handleEvent);
final FocusNode child2 = FocusNode(debugLabel: 'Child 2'); final FocusNode child2 = FocusNode(debugLabel: 'Child 2');
......
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