Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v8.x
Current Behavior
"The Ionic LoadingController, when its loader is dismissed shortly after a route navigation event (NavigationEnd, NavigationCancel, or NavigationError), unexpectedly causes the browser to scroll back to the position it was in before the navigation attempt.
This behavior is observed even when the global scrollPositionRestoration in the Angular router is set to 'disabled'.
Interestingly, setting the keyboardClose property of the LoadingController configuration to false prevents this unwanted scroll restoration. However, this seems like an unintended side effect, as keyboardClose is meant to control whether the loader dismisses when the keyboard is shown.
Expected Behavior
The dismissal of the Ionic loader should not interfere with the browser's scroll position, especially when global scroll restoration is disabled. Ideally, the scroll position should remain where it was after the navigation event (e.g., at the top if no specific scroll behavior is implemented).
Steps to Reproduce
- Navigate to a page with a significant scroll position (Component A).
- Trigger navigation to another page (Component B) that either: Is cancelled (NavigationCancel). Fails (NavigationError).
- Ensure an Ionic loader is presented on NavigationStart and dismissed shortly after the navigation event.
- Observe that after the loader is dismissed (especially in NavigationCancel or NavigationError scenarios), the browser scrolls back to the scroll position of Component A before the navigation was initiated.
Code Reproduction URL
null
Ionic Info
null
Additional Information
Workaround:
Setting keyboardClose: false in the LoadingController configuration prevents this unwanted scroll restoration. However, this is not an intuitive solution and might have unintended side effects on keyboard handling.
Feature Request:
It would be beneficial to have a dedicated property in the LoadingController configuration (e.g., preventScrollResetOnDismiss: boolean) that explicitly controls whether the loader's dismissal should affect the browser's scroll position. This would provide developers with a clear and intentional way to manage this behavior, independent of the keyboardClose property."