mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Update Android view state when accessibility states are changed. (#24678)
Summary: In #24095, we removed the code that changes the underlying Android view's enabled state to false when "disabled" is included in the accessibility states, which seems correct. The Android view's state shouldn't mirror the accessibility state, it should be the other way round-- the accessibility state should represent the state of the view. It seems that the existing test is brokenly setting the disabled state in the Javascript object, and then querying the Android view's enabled state to confirm the change. If the Button implementation is actually the culprit, then IMHO, the correct fix would be to have the Button implementation manipulate the Android View's enabled state, not the accessibilityStates code. [android] [fix] - Fix internal test case around disabled state of buttons Pull Request resolved: https://github.com/facebook/react-native/pull/24678 Differential Revision: D15237590 Pulled By: cpojer fbshipit-source-id: d7ebefbcba9d4d9425da4285175302e4b6435df7
This commit is contained in:
committed by
Facebook Github Bot
parent
2becfabb7d
commit
70e2ab2ec9
@@ -146,11 +146,22 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
return;
|
||||
}
|
||||
view.setTag(R.id.accessibility_states, accessibilityStates);
|
||||
view.setSelected(false);
|
||||
view.setEnabled(true);
|
||||
boolean shouldUpdateContentDescription = false;
|
||||
for (int i = 0; i < accessibilityStates.size(); i++) {
|
||||
String state = accessibilityStates.getString(i);
|
||||
if (sStateDescription.containsKey(state)) {
|
||||
updateViewContentDescription(view);
|
||||
shouldUpdateContentDescription = true;
|
||||
}
|
||||
if (state.equals("selected")) {
|
||||
view.setSelected(true);
|
||||
} else if (state.equals("disabled")) {
|
||||
view.setEnabled(false);
|
||||
}
|
||||
}
|
||||
if (shouldUpdateContentDescription) {
|
||||
updateViewContentDescription(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user