Skip to content

add safeTab(), fail test when page focus is lost#3983

Merged
nstepien merged 4 commits intomainfrom
safeTab()
Feb 26, 2026
Merged

add safeTab(), fail test when page focus is lost#3983
nstepien merged 4 commits intomainfrom
safeTab()

Conversation

@nstepien
Copy link
Collaborator

@nstepien nstepien commented Feb 25, 2026

Upstream bug: microsoft/playwright#39268
Looks like they're petrified by a thorough bug report.

@nstepien nstepien self-assigned this Feb 25, 2026
@nstepien nstepien marked this pull request as ready for review February 25, 2026 18:31
export async function scrollGrid(options: ScrollToOptions) {
page.getGrid().element().scroll(options);
// let the browser fire the 'scroll' event
await new Promise(requestAnimationFrame);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some tests were flaky after scrollGrid(), hopefully this will resolve it.
The scrollend isn't fired when the element isn't scrolled though, but in that case the test will timeout and we'll know why, so we won't unintentionally add useless scrollGrid() calls.

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://playwright.dev/docs/input#scrolling

Do you think we should try

await page.getByTestId('scrolling-container').evaluate(e => e.scrollTop += 100);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Vitest doesn't expose evaluate, probably because tests run in the browser context, rather than in a nodejs context

export async function scrollGrid(options: ScrollToOptions) {
page.getGrid().element().scroll(options);
// let the browser fire the 'scroll' event
await new Promise(requestAnimationFrame);
Copy link
Collaborator

Choose a reason for hiding this comment

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

https://playwright.dev/docs/input#scrolling

Do you think we should try

await page.getByTestId('scrolling-container').evaluate(e => e.scrollTop += 100);

@nstepien nstepien merged commit a80e036 into main Feb 26, 2026
2 checks passed
@nstepien nstepien deleted the safeTab() branch February 26, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants