-
Notifications
You must be signed in to change notification settings - Fork 24.6k
migrate deprecated KEYCODE_BACK in Modal #51097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alanleedev
wants to merge
2
commits into
facebook:main
Choose a base branch
from
alanleedev:export-D74162844
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+81
−17
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request was exported from Phabricator. Differential Revision: D74162844 |
Summary: `Activity.onBackPressed()` has been deprecated and with targetSdk 36 predictive back will be enforced and the API no longer called. Migrate to backward compatible `OnBackPressedCallback`. - https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back So `OnBackPressedCallback` is registered conditionally only if it is targetSdk 36 or greater. If the callback in enabled, `onBackPressed()` is not called and callback is used regardless of `android:enableOnBackInvokedCallback` property in <application> or <activity> set in AndroidManifest.xml As a work around callback is manually calling onBackPressed() NOTE: `ReactDelegate.onHostResume()` sets up the `DefaultHardwareBackBtnHandler` using `ReactActivity` (https://github.com/facebook/react-native/blob/6ad41f9a3f60da87e4b95724199420cab7bed905/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java#L111-L125) Changelog: [Internal] Differential Revision: D74161428
18a30c4
to
0c713e3
Compare
alanleedev
added a commit
to alanleedev/react-native
that referenced
this pull request
May 5, 2025
Summary: **Problem:** `Event.KEYCODE_BACK`has been deprecated with targetSdk 36, predictive back will be enforced and KEYCODE_BACK no longer triggered. We need to migrate to backward compatible `OnBackPressedCallback`. - https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back. **Solution:** Use `OnBackPressedCallback` to handle BACK. Logic for ESC key handling still remains. To support the callback mechanism, we are using AndroidX ComponentDialog ([src](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity/src/main/java/androidx/activity/ComponentDialog.kt)) which is a thin wrapper on the existing Dialog. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D74162844
Summary: Pull Request resolved: facebook#51097 **Problem:** `Event.KEYCODE_BACK`has been deprecated with targetSdk 36, predictive back will be enforced and KEYCODE_BACK no longer triggered. We need to migrate to backward compatible `OnBackPressedCallback`. - https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back. **Solution:** Use `OnBackPressedCallback` to handle BACK. Logic for ESC key handling still remains. To support the callback mechanism, we are using AndroidX ComponentDialog ([src](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity/src/main/java/androidx/activity/ComponentDialog.kt)) which is a thin wrapper on the existing Dialog. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D74162844
This pull request was exported from Phabricator. Differential Revision: D74162844 |
0c713e3
to
8e8a920
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Problem:
Event.KEYCODE_BACK
has been deprecated with targetSdk 36, predictive back will be enforced and KEYCODE_BACK no longer triggered. We need to migrate to backward compatibleOnBackPressedCallback
.Solution:
Use
OnBackPressedCallback
to handle BACK. Logic for ESC key handling still remains.To support the callback mechanism, we are using AndroidX ComponentDialog (src) which is a thin wrapper on the existing Dialog.
Changelog:
[Internal]
Differential Revision: D74162844