Skip to content

Commit

Permalink
Remove custom content description handling
Browse files Browse the repository at this point in the history
Summary:
we are trying to fix the contentdescription reannouncement bug.
This custom handling was added back in 2016. Currently all of the functionality would be performed in super.setContentDescription.
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/View.java#11863

while looking at the method it does exactly the same as we were doing, checking the content of content description, setting it if its different and invalidating the view so it should be safe to delete

Reviewed By: kingsleyadio

Differential Revision: D63534651

fbshipit-source-id: 4c9cc95401c559f02916cc84ee733bc2fdd93c59
  • Loading branch information
Anna Powolny authored and facebook-github-bot committed Sep 30, 2024
1 parent a5e0006 commit 3ca8a23
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions litho-core/src/main/java/com/facebook/litho/ComponentHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -418,34 +418,9 @@ open class ComponentHost(
return contentDescription
}

/**
* Host views implement their own content description handling instead of just delegating to the
* underlying view framework for performance reasons as the framework sets/resets content
* description very frequently on host views and the underlying accessibility notifications might
* cause performance issues. This is safe to do because the framework owns the accessibility state
* and knows how to update it efficiently.
*/
override fun setContentDescription(contentDescription: CharSequence?) {
if (this.contentDescription == null) {
if (contentDescription == null) {
return
}
} else if (this.contentDescription == contentDescription) {
return
}
super.setContentDescription(contentDescription)
this.contentDescription = contentDescription

if (!contentDescription.isNullOrEmpty() &&
ViewCompat.getImportantForAccessibility(this) ==
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES)
}
if (!contentDescription.isNullOrEmpty()) {
// To fix the issue that the TYPE_WINDOW_CONTENT_CHANGED event doesn't get triggered.
// More details at here: https://fburl.com/aoa2apq5
super.setContentDescription(contentDescription)
}
maybeInvalidateAccessibilityState()
}

override fun setTag(key: Int, tag: Any?) {
Expand Down

0 comments on commit 3ca8a23

Please sign in to comment.