fix(prefill): respect loadOnScroll flag in _prefillNext to prevent auto-load in trigger mode (#886)#888
Open
Hoang130203 wants to merge 1 commit intowebcreate:masterfrom
Conversation
…to-load in trigger mode (webcreate#886) When using trigger mode, Trigger.bind() calls ias.disableLoadOnScroll() during the BINDED event. However, prefill._prefillNext() was calling ias.next() directly without checking the loadOnScroll flag, bypassing trigger mode entirely. This caused an unwanted automatic page load on reload when: 1. The user configured trigger mode (no loadOnScroll: false explicitly) 2. The browser restored scroll position near the sentinel 3. Prefill ran and saw distance <= 0, firing next() unconditionally Fix: guard _prefillNext() with a loadOnScroll check so that when trigger mode (or any other mechanism) disables auto-loading, prefill respects it.
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.
Problem
Fixes #886
When using trigger mode, a page load is triggered automatically on reload — even though the user never clicked the trigger button.
Root cause
The flow on reload with trigger mode:
loadOnScroll: true(default — user doesn't need to setloadOnScroll: falseexplicitly when using a trigger)update(pageIndex)→ voter returnstrue→disableLoadOnScroll()✅loadOnScroll = false_prefillNext()→ checksdistance()→ if the browser restored scroll position near the sentinel (withinnegativeMargin),distance <= 0→this.ias.next()is called unconditionally ❌_prefillNext()callednext()directly without checkingloadOnScroll, bypassing the trigger mode guard entirely.Fix
Add a
loadOnScrollcheck at the top of_prefillNext():This is consistent with how the main
HITevent handler ininfinite-ajax-scroll.jsalready guardsnext():Prefill should respect the same flag.
Repro steps
trigger(no explicitloadOnScroll: false)