Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRQ-9559: Fix scrolling by holding pageup/down key #1602

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: focal
language: node_js
node_js:
- lts/*
- node
- 21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert it back. :)

sudo: false
before_install:
- sudo apt-get update
Expand Down
35 changes: 19 additions & 16 deletions useScroll/useEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@
const {keyCode, repeat} = ev;

forward('onKeyDown', ev, props);
ev.preventDefault();

spottable.current.animateOnFocus = true;

Expand Down Expand Up @@ -308,21 +307,25 @@
const pageKeyHandler = (ev) => {
const {keyCode} = ev;

if (Spotlight.getPointerMode() && !Spotlight.getCurrent() && (isPageUp(keyCode) || isPageDown(keyCode))) {
const
{x, y} = lastPointer,
elem = document.elementFromPoint(x, y);

if (elem) {
for (const [key, value] of scrollers) {
if (utilDOM.containsDangerously(value, elem)) {
/* To handle page keys in nested scrollable components,
* break the loop only when `scrollByPageOnPointerMode` returns `true`.
* This approach assumes that an inner scrollable component is
* mounted earlier than an outer scrollable component.
*/
if (key.scrollByPageOnPointerMode(ev)) {
break;
if (isPageUp(keyCode) || isPageDown(keyCode)) {
ev.preventDefault();

Check warning on line 311 in useScroll/useEvent.js

View check run for this annotation

Codecov / codecov/patch

useScroll/useEvent.js#L311

Added line #L311 was not covered by tests

if (Spotlight.getPointerMode() && !Spotlight.getCurrent()) {
const
{x, y} = lastPointer,
elem = document.elementFromPoint(x, y);

Check warning on line 316 in useScroll/useEvent.js

View check run for this annotation

Codecov / codecov/patch

useScroll/useEvent.js#L315-L316

Added lines #L315 - L316 were not covered by tests

if (elem) {
for (const [key, value] of scrollers) {

Check warning on line 319 in useScroll/useEvent.js

View check run for this annotation

Codecov / codecov/patch

useScroll/useEvent.js#L319

Added line #L319 was not covered by tests
if (utilDOM.containsDangerously(value, elem)) {
/* To handle page keys in nested scrollable components,
* break the loop only when `scrollByPageOnPointerMode` returns `true`.
* This approach assumes that an inner scrollable component is
* mounted earlier than an outer scrollable component.
*/
if (key.scrollByPageOnPointerMode(ev)) {
break;

Check warning on line 327 in useScroll/useEvent.js

View check run for this annotation

Codecov / codecov/patch

useScroll/useEvent.js#L327

Added line #L327 was not covered by tests
}
}
}
}
Expand Down
Loading