fix(web): require user intent to cancel initial scroll (#1291)

* fix(web): require user intent to cancel initial scroll

* fix(web): snapshot scroll intent before consumption
This commit is contained in:
SSU-WEI HUANG
2026-08-02 09:27:37 +08:00
committed by GitHub
parent 545af9b4e0
commit f213bc348c
2 changed files with 31 additions and 6 deletions
@@ -200,7 +200,18 @@ describe('scroll anchor helpers', () => {
distanceFromBottom: 182,
isScrollingUp: true
})
expect(shouldCancelInitialScrollSettling(intent)).toBe(true)
expect(shouldCancelInitialScrollSettling(intent, true)).toBe(true)
})
it('keeps initial scroll settling for programmatic upward movement', () => {
const intent = getScrollIntent({
scrollTop: 0,
previousScrollTop: 700,
scrollHeight: 1232,
clientHeight: 530
})
expect(shouldCancelInitialScrollSettling(intent, false)).toBe(false)
})
it('keeps initial scroll settling for negligible movement at the bottom', () => {
@@ -215,7 +226,7 @@ describe('scroll anchor helpers', () => {
distanceFromBottom: 0,
isScrollingUp: false
})
expect(shouldCancelInitialScrollSettling(intent)).toBe(false)
expect(shouldCancelInitialScrollSettling(intent, false)).toBe(false)
})
it('restores the captured message to the same viewport offset', () => {