Avoid announcing text field when it lacks a11y focus (#6830)

* Avoid announcing text field when it lacks a11y focus
This commit is contained in:
Dan Field 2018-11-12 16:08:59 -08:00 committed by GitHub
parent 5fb9b18c6e
commit ea4bbbd440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -763,7 +763,12 @@ class AccessibilityBridge
sendAccessibilityEvent(event);
}
if (mInputFocusedObject != null && mInputFocusedObject.id == object.id
&& object.hadFlag(Flag.IS_TEXT_FIELD) && object.hasFlag(Flag.IS_TEXT_FIELD)) {
&& object.hadFlag(Flag.IS_TEXT_FIELD) && object.hasFlag(Flag.IS_TEXT_FIELD)
// If we have a TextField that has InputFocus, we should avoid announcing it if something
// else we track has a11y focus. This needs to still work when, e.g., IME has a11y focus
// or the "PASTE" popup is used though.
// See more discussion at https://github.com/flutter/flutter/issues/23180
&& (mA11yFocusedObject == null || (mA11yFocusedObject.id == mInputFocusedObject.id))) {
String oldValue = object.previousValue != null ? object.previousValue : "";
String newValue = object.value != null ? object.value : "";
AccessibilityEvent event = createTextChangedEvent(object.id, oldValue, newValue);