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

Missing select event on hidden documents #1253

Open
ph-fritsche opened this issue Jan 15, 2025 · 0 comments
Open

Missing select event on hidden documents #1253

ph-fritsche opened this issue Jan 15, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ph-fritsche
Copy link
Member

Reproduction example

test('events are not dispatched on same microtask in browser', async () => {
const {element} = render<HTMLInputElement>(`<input value="foo"/>`)
const onSelect = mocks.fn()
element.addEventListener('select', onSelect)
element.setSelectionRange(1, 2)
expect(onSelect).toBeCalledTimes(isJsdomEnv() ? 1 : 0)
await waitFor(() => expect(onSelect).toBeCalledTimes(1))
})

image

Prerequisites

  1. Render a form control with selection range (<input type="text">, <textarea>)
  2. Change selection in the form control

Expected behavior

A select event is dispatched.

Actual behavior

There is no select event if document.visibilityState is hidden.

User-event version

14.5.2

Environment

DOM implementation: Chromium 131.0.6778.204 built on Debian GNU/Linux 12 (bookworm)

Additional context

similar to #553

@ph-fritsche ph-fritsche added the bug Something isn't working label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant