Skip to content

Commit 58fac77

Browse files
authored
fix(browser): don't release keyboard automatically (#6083)
1 parent ee72518 commit 58fac77

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/browser/src/node/commands/keyboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const keyboard: UserEventCommand<UserEvent['keyboard']> = async (
5050
throw new TypeError(`Provider "${context.provider.name}" does not support selecting all text`)
5151
}
5252
},
53-
false,
53+
true,
5454
)
5555
}
5656

test/browser/test/userEvent.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,22 @@ describe('userEvent.keyboard', async () => {
557557
])
558558
})
559559

560+
test('should not auto release', async () => {
561+
const spyKeydown = vi.fn()
562+
const spyKeyup = vi.fn()
563+
const button = document.createElement('button')
564+
document.body.appendChild(button)
565+
button.addEventListener('keydown', spyKeydown)
566+
button.addEventListener('keyup', spyKeyup)
567+
button.focus()
568+
await userEvent.keyboard('{Enter>}')
569+
expect(spyKeydown).toHaveBeenCalledOnce()
570+
expect(spyKeyup).not.toHaveBeenCalled()
571+
await userEvent.keyboard('{/Enter}')
572+
// userEvent doesn't fire any event here, but should we?
573+
expect(spyKeyup).not.toHaveBeenCalled()
574+
})
575+
560576
test('standalone keyboard works correctly with active input', async () => {
561577
const documentKeydown: string[] = []
562578
const inputKeydown: string[] = []

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy