Skip to content

Commit

Permalink
fix(android): prevent rehydration on destroyed dialogs (#10414)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcassidyav committed Oct 24, 2023
1 parent e8c093d commit 7563549
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/core/ui/core/view/index.android.ts
Expand Up @@ -173,7 +173,16 @@ function initializeDialogFragment() {

return global.__native(this);
}

public onCreate(savedInstanceState: android.os.Bundle) {
super.onCreate(savedInstanceState);
var ownerId = this.getArguments()?.getInt(DOMID);
var options = getModalOptions(ownerId);
// The teardown when the activity is destroyed happens after the state is saved, but is not recoverable,
// Cancel the native dialog in this case or the app will crash with subsequent errors.
if (savedInstanceState != null && options === undefined) {
this.dismissAllowingStateLoss();
}
}
public onCreateDialog(savedInstanceState: android.os.Bundle): android.app.Dialog {
const ownerId = this.getArguments().getInt(DOMID);
const options = getModalOptions(ownerId);
Expand Down

0 comments on commit 7563549

Please sign in to comment.