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

feat: add option to set element class on hover #1212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rChaoz
Copy link

@rChaoz rChaoz commented Apr 18, 2024

What:

Add option to set a class on target element on hover. Useful for testing hover states either by manually adding .my-hover-class on top of :hover in CSS or with a plugin such as the one for PostCSS or Storybook.

Why:

Allow testing of CSS hover states using userEvent.hover / userEvent.unhover or other commands that move the mouse.

How:

Add a new config option hoverClass (string) which defaults to null. When set (non-null), target.classList.add(hoverClass) is called whenever mouseenter is emitted and target.classList.remove(hoverClass) whenever mouseleave is emitted.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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

1 participant