This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Fixed ios layout change to not refocus semantics object if the focus … #21029
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification, | |
| : view_controller_(view_controller), | ||
| platform_view_(platform_view), | ||
| platform_views_controller_(platform_views_controller), | ||
| last_focused_semantics_object_id_(0), | ||
| last_focused_semantics_object_id_(-1), | ||
| objects_([[NSMutableDictionary alloc] init]), | ||
| weak_factory_(this), | ||
| previous_route_id_(0), | ||
|
|
@@ -67,10 +67,15 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification, | |
| return [[platform_view_->GetOwnerViewController().get().engine textInputPlugin] textInputView]; | ||
| } | ||
|
|
||
| void AccessibilityBridge::AccessibilityFocusDidChange(int32_t id) { | ||
| void AccessibilityBridge::AccessibilityObjectDidBecomeFocused(int32_t id) { | ||
| last_focused_semantics_object_id_ = id; | ||
| } | ||
|
|
||
| void AccessibilityBridge::AccessibilityObjectDidLoseFocus(int32_t id) { | ||
| if (last_focused_semantics_object_id_ == id) | ||
| last_focused_semantics_object_id_ = -1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you do a define for this magic value, something like |
||
| } | ||
|
|
||
| void AccessibilityBridge::UpdateSemantics(flutter::SemanticsNodeUpdates nodes, | ||
| flutter::CustomAccessibilityActionUpdates actions) { | ||
| BOOL layoutChanged = NO; | ||
|
|
@@ -198,22 +203,28 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification, | |
| nextToFocus); | ||
| } | ||
| } else if (layoutChanged) { | ||
| // Tries to refocus the previous focused semantics object to avoid random jumps. | ||
| SemanticsObject* nextToFocus = | ||
| [objects_.get() objectForKey:@(last_focused_semantics_object_id_)]; | ||
| if (!nextToFocus && root) { | ||
| nextToFocus = FindFirstFocusable(root); | ||
| SemanticsObject* nextToFocus = nil; | ||
| // This property will be -1 if the focus is outside of the flutter | ||
| // application. In this case, we should not refocus anything. | ||
| if (last_focused_semantics_object_id_ != -1) { | ||
| // Tries to refocus the previous focused semantics object to avoid random jumps. | ||
| nextToFocus = [objects_.get() objectForKey:@(last_focused_semantics_object_id_)]; | ||
| if (!nextToFocus && root) { | ||
| nextToFocus = FindFirstFocusable(root); | ||
| } | ||
| } | ||
| ios_delegate_->PostAccessibilityNotification(UIAccessibilityLayoutChangedNotification, | ||
| nextToFocus); | ||
| } else if (scrollOccured) { | ||
| // TODO(chunhtai): figure out what string to use for notification. At this | ||
| // point, it is guarantee the previous focused object is still in the tree | ||
| // so that we don't need to worry about focus lost. (e.g. "Screen 0 of 3") | ||
| SemanticsObject* nextToFocus = | ||
| [objects_.get() objectForKey:@(last_focused_semantics_object_id_)]; | ||
| if (!nextToFocus && root) { | ||
| nextToFocus = FindFirstFocusable(root); | ||
| SemanticsObject* nextToFocus = nil; | ||
| if (last_focused_semantics_object_id_ != -1) { | ||
| nextToFocus = [objects_.get() objectForKey:@(last_focused_semantics_object_id_)]; | ||
| if (!nextToFocus && root) { | ||
| nextToFocus = FindFirstFocusable(root); | ||
| } | ||
| } | ||
| ios_delegate_->PostAccessibilityNotification(UIAccessibilityPageScrolledNotification, | ||
| nextToFocus); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add curly braces to make turning the linter on for mac easier.