Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6ff2b0f

Browse files
Focus fix
1 parent 15f9811 commit 6ff2b0f

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

shell/platform/common/accessibility_bridge.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,12 @@ void AccessibilityBridge::SetTooltipFromFlutterUpdate(
527527
void AccessibilityBridge::SetTreeData(const SemanticsNode& node,
528528
ui::AXTreeUpdate& tree_update) {
529529
FlutterSemanticsFlag flags = node.flags;
530-
// Set selection if:
530+
// Set selection of the focused node if:
531531
// 1. this text field has a valid selection
532532
// 2. this text field doesn't have a valid selection but had selection stored
533533
// in the tree.
534-
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField) {
534+
if (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
535+
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused) {
535536
if (node.text_selection_base != -1) {
536537
tree_update.tree_data.sel_anchor_object_id = node.id;
537538
tree_update.tree_data.sel_anchor_offset = node.text_selection_base;

shell/platform/windows/accessibility_bridge_windows.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ void AccessibilityBridgeWindows::OnAccessibilityEvent(
4242
ax::mojom::Event::kChildrenChanged);
4343
break;
4444
case ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED: {
45+
// An event indicating a change in document selection should be fired
46+
// only for the focused node whose selection has changed.
4547
ui::AXNode::AXID focus_id = GetAXTreeData().sel_focus_object_id;
4648
auto focus_delegate =
4749
GetFlutterPlatformNodeDelegateFromID(focus_id).lock();
48-
DispatchWinAccessibilityEvent(
49-
std::static_pointer_cast<FlutterPlatformNodeDelegateWindows>(
50-
focus_delegate),
51-
ax::mojom::Event::kDocumentSelectionChanged);
50+
if (focus_delegate) {
51+
DispatchWinAccessibilityEvent(
52+
std::static_pointer_cast<FlutterPlatformNodeDelegateWindows>(
53+
focus_delegate),
54+
ax::mojom::Event::kDocumentSelectionChanged);
55+
}
5256
break;
5357
}
5458
case ui::AXEventGenerator::Event::FOCUS_CHANGED:

0 commit comments

Comments
 (0)