Closed Bug 1827975 Opened 2 years ago Closed 2 years ago

Scrollend fires on keyboard scrolls that don't change scroll position

Categories

(Core :: Layout: Scrolling and Overflow, defect, P3)

Firefox 114
defect

Tracking

()

VERIFIED FIXED
121 Branch
Tracking Status
firefox121 --- verified

People

(Reporter: awogbemila, Assigned: dlrobertson)

References

Details

Attachments

(2 files)

Steps to reproduce:

Please view this codepen: https://codepen.io/awogbemila/pen/zYmrRVV
The div should be scrolled all the way up (scrollTop is 0).
Press and release the up arrow key
Observe that scrollend is fired even though no scrolling happened (scrollend count is incremented).

You can also scroll the div all the way down and then press and release arrow down.
You'll see that scrollend is fired even though no scrolling happened.

Actual results:

Scrollend events fire to the div even though the div does not actually scroll (scrollTop does not change).

Expected results:

Scrollend events should not fire since there was no scrolling as this working group spec notes[1].
Also note that firefox behaves differently with mouse wheels: when no scrolling happens, it does not fire scrollend which I believe is the correct behavior.

[1] https://drafts.csswg.org/cssom-view/#scrolling

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Scrolling and Overflow' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Scrolling and Overflow
Product: Firefox → Core

Good catch! On mac I don't see this, but I don't see scrollend events fired for keyboard scrolls that should fire scrollend events. What OS did you see this on?

Flags: needinfo?(awogbemila)

I am able to see the events on Linux. The events come from here in nsHTMLScrollFrame::SetTransformingByAPZ.

Hmm, originally I saw this running firefox on Linux but I've tried it on mac as well and I see it there too.

On a somewhat related note: this issue will affect a wpt: https://wpt.fyi/results/dom/events/scrolling/scrollend-event-not-fired-on-no-scroll.html?label=master&label=experimental&aligned&q=scrollend which tests this use case though it is currently masked by another issue which I filed
https://bugzilla.mozilla.org/show_bug.cgi?id=1827912 for.

Flags: needinfo?(awogbemila)

I can reproduce this on Linux as well.

(In reply to Dan Robertson (:dlrobertson) from comment #2)

On mac I [...] don't see scrollend events fired for keyboard scrolls that should fire scrollend events.

That might be worth filing an additional bug about for tracking purposes.

Severity: -- → S3
Priority: -- → P3
See Also: → 1831580
Status: UNCONFIRMED → NEW
Ever confirmed: true

I’m testing in Firefox Nightly on macOS.

When I click the scroll container and then press and hold down the Space bar, the scrollend counter keeps increasing indefinitely, even after the end of the scroll container was reached.

In Chrome, the scrollend counter increases by 2. I guess the logic is, one for pressing Space bar, and another one for holding it down.

When a APZC handles a keyboard scroll or other smooth scroll,
no scrollend event should be fired if the scroll position will not
change as a result of the scroll.

Assignee: nobody → drobertson
Status: NEW → ASSIGNED

Add scrollend event tests for keyboard scrolls.

Depends on D187050

Pushed by drobertson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8d034bde14e5 Do not fire scrollend events for keyboard scrolls that do not change the scroll position. r=hiro https://hg.mozilla.org/integration/autoland/rev/87f29c301be9 Add scrollend tests for keyboard scrolls. r=hiro

Backed out for causing mochitests failures in test_group_scrollend.html.

Flags: needinfo?(drobertson)
Regressions: 1856245

Updating the test now.

Flags: needinfo?(drobertson)
Pushed by drobertson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/93a891338556 Do not fire scrollend events for keyboard scrolls that do not change the scroll position. r=hiro https://hg.mozilla.org/integration/autoland/rev/d9d3c8186de0 Add scrollend tests for keyboard scrolls. r=hiro

Fixed and running some more tests on try. I should have caught the scrollend tests in wpt that we now pass.

Flags: needinfo?(drobertson)
Pushed by drobertson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/15086b08cea5 Do not fire scrollend events for keyboard scrolls that do not change the scroll position. r=hiro https://hg.mozilla.org/integration/autoland/rev/7ce85e940886 Add scrollend tests for keyboard scrolls. r=hiro

The failing test will be fixed by scroll position rounding, but perhaps we should put in place a workaround of some kind.

Flags: needinfo?(drobertson)
Pushed by drobertson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dab9c40ca808 Do not fire scrollend events for keyboard scrolls that do not change the scroll position. r=hiro https://hg.mozilla.org/integration/autoland/rev/c02a1959f381 Add scrollend tests for keyboard scrolls. r=hiro
Regressions: 1862063
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch

Reproduced the issue with Firefox 114.0a1 (2023-04-13) on Windows 10x64. Pressing the UP arrow keyboard key on the test codepen from comment 0 will increase the scrolled count.
The issue is verified fixed with Firefox 121.0b3 on Windows 10x64, macOS 12 and Ubuntu 22. The scrolled count is no longer increased after following STR from comment 0.

Status: RESOLVED → VERIFIED
Has STR: --- → yes
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: