fix(computer): move the macOS caret only after the text write lands (#41541)

When a field accepted the AX value write but kept its old value, the
helper had already moved the caret, so the fallback keys or Cmd+V went
in at the wrong place.
This commit is contained in:
Kelvin Amoaba
2026-11-12 12:55:02 +00:00
committed by GitHub
parent fbec96cf29
commit 02f5c8a88b
@@ -2978,14 +2978,15 @@ private enum TextInput {
guard result == .success else {
return nil
}
setSelectedTextRange(element, CFRange(location: startOffset + text.utf16.count, length: 0))
// Why: a cached, out-of-process AX tree can show the old value for a moment; any other value is final.
let readback = settledValueReadback(element) { next == current || ($0 as? String) != current } as? String
// Why: typing the text as keys after a write that landed enters it twice, so only an unchanged field falls back.
if readback == current && next != current {
return nil
}
// Why: moving the caret before a refused write would send the fallback keys to the wrong place.
setSelectedTextRange(element, CFRange(location: startOffset + text.utf16.count, length: 0))
guard readback == next else {
// Why: typing the text as keys after a write that landed enters it twice, so only an unchanged field falls back.
if readback == current {
return nil
}
return unverifiedAction(reason: "accessibility_action_unasserted")
}
return verifiedAction(property: "focusedText")