From da47abb001b033e8c10cbcd4ca8c7386da1f18b0 Mon Sep 17 00:00:00 2001 From: peterhegman Date: Tue, 25 May 2021 07:55:50 -0600 Subject: [PATCH] docs(test-utils): add tip about using `trigger('focus')` When using `trigger('focus')` with jsdom v16.4.0 and above you must use `attachTo` when mounting the component. --- docs/api/wrapper/trigger.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/api/wrapper/trigger.md b/docs/api/wrapper/trigger.md index 74e3e88bf..3d8720bb3 100644 --- a/docs/api/wrapper/trigger.md +++ b/docs/api/wrapper/trigger.md @@ -38,6 +38,10 @@ test('trigger demo', async () => { }) ``` +::: tip +When using `trigger('focus')` with [jsdom v16.4.0](https://github.com/jsdom/jsdom/releases/tag/16.4.0) and above you must use the [attachTo](../options.md#attachto) option when mounting the component. This is because a bug fix in [jsdom v16.4.0](https://github.com/jsdom/jsdom/releases/tag/16.4.0) changed `el.focus()` to do nothing on elements that are disconnected from the DOM. +::: + - **Setting the event target:** Under the hood, `trigger` creates an `Event` object and dispatches the event on the Wrapper element.