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

docs(test-utils): add tip about using trigger('focus') #1848

Merged
merged 1 commit into from
May 26, 2021

Conversation

phegman
Copy link
Contributor

@phegman phegman commented May 19, 2021

Per #1777 (comment) this PR adds a tip to the documentation about how attachTo is needed when using trigger('focus') with jsdom v16.4.0 and above

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe: Docs

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

#1777 (comment)

@phegman
Copy link
Contributor Author

phegman commented May 19, 2021

@lmiller1990 follow-up to #1777. Can you take a look at this when you have time?

@@ -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 `el.focus()` does not work on elements that are disconnected from the DOM.
Copy link
Member

Choose a reason for hiding this comment

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

Is this a bug in versions of jsdom earlier or later than 16.4.0? Might be good to specify.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lmiller1990 It looks like jsdom does consider this change a bug fix. I have updated the tip text to say:

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.

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Perfect

When using `trigger('focus')` with jsdom v16.4.0 and above you must
use `attachTo` when mounting the component.
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.

None yet

2 participants