Repository navigation
Keep Android disabled-state resets scoped to core views - #58795
meta-codesync[bot] merged 1 commit into
Conversation
|
Can we fix this on the Android side instead? The absence of the attributed should be treated as false. |
|
Updated this PR with an Android-side fix and regression tests covering the text-input editability and partial-update issues reproduced in #58799. |
Summary: JSI drops `undefined` keys, so reseting `disabled` from `true` to `undefined` on Touchables/Pressables never runs `setEnabled(true)` There is props diffing feature flag that fixes this, which is off by default Also added safety check against explicit `null` & reset on recycling Fixes #56777 and supersedes #58795 ## Changelog: [ANDROID] [FIXED] - Properly enable Pressable after `disabled` prop resets from `true` Pull Request resolved: #58799 Test Plan: Added BaseViewManagerTest as well as videos of testing it on Pressable: https://github.com/user-attachments/assets/e9a7dcd2-46d5-4cdc-88a3-728bff22e76b https://github.com/user-attachments/assets/043150ae-64f2-47c9-b13c-abfec5b61747 Reviewed By: javache Differential Revision: D122872380 Pulled By: zeyap fbshipit-source-id: f3f1cad378f36f006bbb6c7f3f2e4f9aa8e61541
Summary: JSI drops `undefined` keys, so reseting `disabled` from `true` to `undefined` on Touchables/Pressables never runs `setEnabled(true)` There is props diffing feature flag that fixes this, which is off by default Also added safety check against explicit `null` & reset on recycling Fixes #56777 and supersedes #58795 ## Changelog: [ANDROID] [FIXED] - Properly enable Pressable after `disabled` prop resets from `true` Pull Request resolved: #58799 Test Plan: Added BaseViewManagerTest as well as videos of testing it on Pressable: https://github.com/user-attachments/assets/e9a7dcd2-46d5-4cdc-88a3-728bff22e76b https://github.com/user-attachments/assets/043150ae-64f2-47c9-b13c-abfec5b61747 Reviewed By: javache Differential Revision: D122872380 Pulled By: zeyap fbshipit-source-id: f3f1cad378f36f006bbb6c7f3f2e4f9aa8e61541 (cherry picked from commit 357b699)
javache
left a comment
There was a problem hiding this comment.
Making resetDisabledFromAccessibilityState an instance method seems legit, but the class-based check isn't.
The default .isEnabled handling should stay in ReactViewManager - maybe pull the view.setTag(R.id.accessibility_state_disabled, null); into setViewState, so view managers don't need to call super? ReactTextInputManagerdoesn't derive fromReactViewManager` so wouldn't auto-derive this behaviour.
Summary: JSI drops `undefined` keys, so reseting `disabled` from `true` to `undefined` on Touchables/Pressables never runs `setEnabled(true)` There is props diffing feature flag that fixes this, which is off by default Also added safety check against explicit `null` & reset on recycling Fixes react#56777 and supersedes react#58795 ## Changelog: [ANDROID] [FIXED] - Properly enable Pressable after `disabled` prop resets from `true` Pull Request resolved: react#58799 Test Plan: Added BaseViewManagerTest as well as videos of testing it on Pressable: https://github.com/user-attachments/assets/e9a7dcd2-46d5-4cdc-88a3-728bff22e76b https://github.com/user-attachments/assets/043150ae-64f2-47c9-b13c-abfec5b61747 Reviewed By: javache Differential Revision: D122872380 Pulled By: zeyap fbshipit-source-id: f3f1cad378f36f006bbb6c7f3f2e4f9aa8e61541 (cherry picked from commit 357b699)
da5578d to
e0a9ab5
Compare
Clearing accessibilityState.disabled re-enabled every view whose
disabled state came from accessibility, so a TextInput with
editable={false} became editable again.
BaseViewManager now tracks and clears the accessibility disabled tag in
setViewState and calls the protected resetDisabledFromAccessibilityState
hook only when accessibility had disabled the view. The base hook does
nothing; ReactViewManager overrides it to re-enable the view, so core
views and their subclasses keep the Pressable fix while other managers
keep the enabled state they control.
e0a9ab5 to
c608cdc
Compare
Visual regressionNo visual differences at ios: no capture |
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D133495913. |
|
This pull request was successfully merged by @Marve10s in 45dd67d When will my fix make it into a release? | How to file a pick request? |
Summary:
#58799 fixed the original Pressable tap-target reset on
main. This follow-up keeps that reset inReactViewManager. Applying it in every manager can re-enable a non-editableTextInputwhen accessibility disabled is cleared, becauseReactTextInputManagerdoes not derive fromReactViewManagerand controls its enabled state througheditable.BaseViewManagernow has a protected instance hook,resetDisabledFromAccessibilityState, that does nothing by default.ReactViewManageroverrides it to restore the enabled state that accessibility disabled took away, so its subclasses get the same behavior without a class check.setViewStateclears the disabled tag itself, so view managers don't need to call super. Other managers keep the enabled state they control.Since this PR was opened, #59387 started sending the full
accessibilityStatewith Props 2.0 and #59047 re-enables views on recycle, so the earlier C++ prop change and theReactViewGroupchange are no longer part of this PR. The JavaScript components are unchanged.Changelog:
[ANDROID] [FIXED] - Preserve non-editable text inputs when accessibility disabled is cleared.
Test plan:
With the Android SDK, JDK 21, and Yarn v1 on the environment path:
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \ --tests com.facebook.react.uimanager.BaseViewManagerTest \ --tests com.facebook.react.views.textinput.ReactTextInputPropertyTest \ --tests com.facebook.react.views.view.ReactViewGroupTest \ -Preact.internal.useHermesStable=true --no-daemon --max-workers=2 \ -Dorg.gradle.jvmargs='-Xmx2g -XX:MaxMetaspaceSize=768m' --console=plainAll 82 tests pass. The non-editable
TextInputtest fails onmainand passes with this change. AReactViewManagersubclass test checks that subclasses inherit the reset.The
ReactAndroid.apilines were checked against the compiled classes withjavap. No full Android build, emulator, or device test was run.