ionic-team / ionic-team/ionic-framework

bug: infinite-scroll, didFire can get stuck at true when items are removed dynamically

未关闭
#28,272 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: bug
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/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 include this feature request, without success.

### Describe the Feature Request

Hi,

Infinite scroll component can "lock" if used on a scrollable element whose height changes by removing elements.

In the docs is not clear whether the component officially supports removing items/reducing height, as I always used it in the classic way of just showing more content by expanding it.

In my case, without a API hook to reset state, everytime I change the content size I simply remove it from the DOM with a *ngIf, and then i put it back.

Would be nice to have a reset() method or something like that.

### Describe the Use Case

After the first time you triggered the ionInfinite event, and correctly added stuff and call complete(), if for some reason you remove stuff and reduce height to 1 "page" you are stuck unable to call more content, as the infinitescroll component is in the "didFire ==true" state (you're still in the threshold zone), and wont fire the event again.
The component expects the scroll component to expand and only resets state when the scroll position exits the threshold zone.

### Describe Preferred Solution

The easiest way is to let the component fire the ionInfinite event in that edge case by resetting that particular state (didFire) via a public method, so it can be called every time we reduce height.

### Describe Alternatives

A workaround to this behaviour is removing the infinite scroll component from the DOM and reinsert it.

### Related Code

[stackblitz](https://stackblitz.com/edit/ionic7-angular15-qnkfgm?file=src%2Fapp%2Fapp.component.ts)

To reproduce pls trigger infinite scroll, then press "reduce elements" till it stops working.

### Additional Information

_No response_

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。