fix(infinite-scroll): remaining in threshold after ionInfinite can trigger event again on scroll - #28569
Merged
Conversation
…igger event again on scroll
This reverts commit c9f2b2b.
liamdebeasi
marked this pull request as ready for review
November 21, 2023 21:42
liamdebeasi
requested review from
a team and
brandyscarney
and removed request for
a team
November 22, 2023 15:26
thetaPC
approved these changes
Nov 28, 2023
thetaPC
left a comment
Contributor
There was a problem hiding this comment.
LGTM, no issues when testing top and bottom. Minor question, but doesn't block.
…x.html Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
averyrousseau
approved these changes
Dec 4, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #18071
What is the current behavior?
When adding elements to the DOM in the
ionInfinitecallback, scrolling again would sometimes not causeionInfiniteto trigger again. We set the didFire flag totruebefore callingionInfinite. This flag ensures thationInfiniteis not called multiple times if users continue to scroll afterionInfiniteis fired but before thecompletemethod is called.The didFire flag is reset once the user scrolls outside of the threshold. Normally this is fine: If an application adds several new items to a list the current scroll position will be outside of the threshold. However, if the scroll position remains in the threshold (such as if an application append a small number of new items to a list) then the
didFireflag will not get reset.Additionally, there are some instances where the scroll position restoration when
position="top"may not work which can cause this bug to trigger as well. For example, if users quickly scroll to the top, the scroll position will not be restored correctly and the scroll position will still be at the top of the screen. That is another instance where this bug can trigger even if a large number of items were added to the DOM.What is the new behavior?
didFireflag is reset when thecompletemethod is called. This ensures that even if the scroll position is still in the thresholdionInfinitecan fire again.Note that developers may notice
ionInfinitefiring more times as a result of this change. This can happen when appending a small number of items to the DOM such that the scroll position remains in the threshold. PreviouslyionInfinitewould not fire again, but now it does since users are scrolling in the threshold. I decided to target this change for a minor release to minimize any surprises for developers.Does this introduce a breaking change?
Other information
Dev build:
7.5.4-dev.11700602203.1e7155a1