ionic-team / ionic-team/ionic-framework

bug: Scroll position not restored when navigating back

Đang mở
#29,578 8 bình luận 2 reaction 0 người được giao Xem trên GitHub
type: bug
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

v8.x

### Current Behavior

Scroll position is not restored when I navigate back to the previous page, it scrolls me to the top of the page

It's really annoying when you want to open the details of an item, then go back, then want to open another item details, etc...

### Expected Behavior

In v7 of Ionic, it would keep the previous scroll position, so that navigating back and forth between pages was smooth

### Steps to Reproduce

I forked the stackblitz demo of https://ionicframework.com/docs/api/nav#using-navlink and just added some fake content so that the page are tall enough to be scrollable.

Steps:

1. scroll to the bottom
2. click on "go to page two"
3. click on the arrow to go back
4. the first page's scroll position is not restored and you have to scroll back again to the bottom

It was not the case in Ionic v7

### Code Reproduction URL

https://stackblitz.com/edit/ultfxy?file=index.html

### Ionic Info

```
Ionic:
Ionic CLI : 7.2.0 (/home/jmarcou/.nvm/versions/node/v20.14.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 8.2.0
@angular-devkit/build-angular : 18.0.2
@angular-devkit/schematics : 18.0.2
@angular/cli : 18.0.2
@ionic/angular-toolkit : not installed

Capacitor:
Capacitor CLI : 6.0.0
@capacitor/android : 6.0.0
@capacitor/core : 6.0.0
@capacitor/ios : not installed

Utility:
cordova-res : not installed globally
native-run : 2.0.1

System:
NodeJS : v20.14.0 (/home/jmarcou/.nvm/versions/node/v20.14.0/bin/node)
npm : 10.8.1
OS : Linux 5.15
```

### Additional Information

_No response_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the linked StackBlitz reproduction and the navigation behavior described in the issue, then trace the Ionic Angular navigation path used by the NavLink example. The fix is done when navigating back restores the previous page's scroll position in the v8 scenario without breaking forward navigation; verify against the listed reproduction steps.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.