OnBackPressed not called with modal open
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
After upgrading from .NET8 to .NET9 the android activity's `onBackPressed` is no longer called if a modal page is open.
### Steps to Reproduce
1. Open the repo project on master branch (.NET8)
2. Click the button to open a modal page
3. Press the android back button
4. Observe `MainActivity.OnBackPressed` is called first then `MainPage.OnBackButtonPressed` is called.
5. Switch to net9 branch (.NET9)
6. Redo the same steps as before.
7. Observe `MainPage.OnBackButtonPressed` is called but not `MainActivity.OnBackPressed`
### Link to public reproduction project repository
https://github.com/WillMDK/modalnavigation
### Version with bug
9.0.40 SR4
### Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
### Last version that worked well
8.0.100 SR10
### Affected platforms
Android
### Affected platform versions
Android 14
### Did you find any workaround?
_No response_
### Relevant log output
```shell
.NET8:
[0:] MainActivity OnBackPressed called
[0:] MainPage OnBackButtonPressed called
.NET9:
[0:] MainPage OnBackButtonPressed called
```
Contributor guide
Research direction
Start with the public reproduction project at github.com/WillMDK/modalnavigation and compare its master (.NET 8) and net9 branches on Android 14. Trace the back-button flow through MainActivity.OnBackPressed and MainPage.OnBackButtonPressed; done means the .NET 9 behavior restores the expected callback sequence and the reproduction logs match .NET 8.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100