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-9560: Fix scrolling by pageup/down key depending on pointer focus #1584

Open
wants to merge 6 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
4 changes: 3 additions & 1 deletion ThemeDecorator/ThemeDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ const ThemeDecorator = hoc(defaultConfig, (config, Wrapped) => {
405, // yellow
406, // blue
33, // channel up
34 // channel down
34, // channel down
35, // end
36 // home
],
red: 403,
green: 404,
Expand Down
37 changes: 37 additions & 0 deletions tests/ui/specs/Scroller/Scroller-nativeScroll-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,41 @@ describe('Scroller', function () {
expect((await ScrollerPage.getScrollThumbPosition()).horizontal > initialHorizontalScrollThumbPosition).to.be.true();
});
});

describe('Page Scroll', function () {
it('should scroll with pressed pageUp/Down key only when focus is in the Scroller.', async function () {
await ScrollerPage.open();
let verticalScrollTumbPosition = (await ScrollerPage.getScrollThumbPosition()).vertical;
// Scroll thumb is on the initial position
expect(await verticalScrollTumbPosition).to.equal('0');
// Move focus to Scroller
await ScrollerPage.scroller.moveTo();
// Scroll by pageDown key
await ScrollerPage.pageDown();
await ScrollerPage.delay(1000);
verticalScrollTumbPosition = (await ScrollerPage.getScrollThumbPosition()).vertical;
// Scroller is scrolled and scroll thumb is moved
expect(await verticalScrollTumbPosition).not.to.equal('0');
// Scroll by pageUp key
await ScrollerPage.pageUp();
await ScrollerPage.delay(1000);
verticalScrollTumbPosition = (await ScrollerPage.getScrollThumbPosition()).vertical;
// Scroller is scrolled and scroll thumb is moved to initial position
expect(await verticalScrollTumbPosition).to.equal('0');
// Move focus to buttonHideScrollbar
await ScrollerPage.buttonHideScrollbar.moveTo();
// Press pageDown key
await ScrollerPage.pageDown();
await ScrollerPage.delay(1000);
verticalScrollTumbPosition = (await ScrollerPage.getScrollThumbPosition()).vertical;
// Scroller is not scrolled and scroll thumb is not moved
expect(await verticalScrollTumbPosition).to.equal('0');
// Press pageUp key
await ScrollerPage.pageUp();
await ScrollerPage.delay(1000);
verticalScrollTumbPosition = (await ScrollerPage.getScrollThumbPosition()).vertical;
// Scroller is not scrolled and scroll thumb is not moved
expect(await verticalScrollTumbPosition).to.equal('0');
});
});
});
32 changes: 32 additions & 0 deletions tests/ui/specs/VirtualList/VirtualList/VirtualList-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,36 @@ describe('VirtualList', function () {
await expectFocusedItem(5, 'focus Item 05');
});
});

describe('Page Scroll', function () {
it('should scroll with pressed pageUp/Down key only when focus is in the VirtualList.', async function () {
await Page.open();
// Scroll thumb is on the initial position
expect(await Page.getScrollThumbPosition()).to.equal('0');
// Move focus to VirtualList
await (await Page.item(0)).moveTo();
// Scroll by pageDown key
await Page.pageDown();
await Page.delay(1000);
// VirtualList is scrolled and scroll thumb is moved
expect(await Page.getScrollThumbPosition()).not.to.equal('0');
// Scroll by pageUp key
await Page.pageUp();
await Page.delay(1000);
// VirtualList is scrolled and scroll thumb is moved to initial position
expect(await Page.getScrollThumbPosition()).to.equal('0');
// Move focus to buttonHideScrollbar
await (await Page.buttonHideScrollbar).moveTo();
// Press pageDown key
await Page.pageDown();
await Page.delay(1000);
// VirtualList is not scrolled and scroll thumb is not moved
expect(await Page.getScrollThumbPosition()).to.equal('0');
// Press pageUp key
await Page.pageUp();
await Page.delay(1000);
// VirtualList is not scrolled and scroll thumb is not moved
expect(await Page.getScrollThumbPosition()).to.equal('0');
});
});
});
1 change: 1 addition & 0 deletions useScroll/useEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
const {keyCode} = ev;

if (Spotlight.getPointerMode() && !Spotlight.getCurrent() && (isPageUp(keyCode) || isPageDown(keyCode))) {
ev.preventDefault();

Check warning on line 312 in useScroll/useEvent.js

View check run for this annotation

Codecov / codecov/patch

useScroll/useEvent.js#L312

Added line #L312 was not covered by tests
const
{x, y} = lastPointer,
elem = document.elementFromPoint(x, y);
Expand Down
Loading