Tailwind hidden class but change on group-hover
See original GitHub issueCurrent behavior
I have a child element that has a group-hover class. Which basically, it detect if the parent is hovered, then the child should change the value based on what we put.
In this child element, my manual class is “hidden” , but change /overwritten when the parent is on hover.
But in cypress, it always detect this tailwind hidden class
This element `<div>` is not visible because its parent `<div.hidden.group-hover:flex.absolute.w-11/12.bottom-20.left-0.right-0.mx-auto.p-2.bg-white.border.rounded-xl.shadow-sm.space-x-2>` has CSS property: `display: none`
Desired behavior
If the value display is overwritten then we should be able to perform action such as click on this element
Test code to reproduce
Element
<div
id={`wrapper-pdf-page-1`}
className="relative group">
...
<div data-cy='removeBtn' className="hidden group-hover:flex">
REMOVE
</div>
</div>
Test
// hover on a page
it('should hover on a page', () => {
cy.get('#wrapper-pdf-page-1').trigger('onmouseover')
cy.get('#wrapper-pdf-page-1').trigger('mouseenter')
cy.get('[data-cy="removeBtn"]').first().click()
// check '#wrapper-pdf-page-1' removed
cy.get('#wrapper-pdf-page-1').should('not.exist')
})
Cypress Version
^10.11.0
Node version
16
Operating System
macoS
Debug Logs
No response
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Displaying button when hovering over div in TailwindCSS
Wilth tailwind 3, this works with small changes: add group class to the parent div. Change hover in button to group-hover and everything...
Read more >Handling Hover, Focus, and Other States - Tailwind CSS
In Tailwind, rather than adding the styles for a hover state to an existing class, you add another class to the element that...
Read more >Revealing hidden elements when hovering a parent with ...
Tailwind is capable of doing that with group hover. For this example, we're going to reach for a lesser used css attribute: visibility...
Read more >Tailwind group hover, the state you missed - Daily Dev Tips
Tailwind group hover effect Let's first take a look at how this effect works. It needs to have a group class on the...
Read more >Creating hover effects with Tailwind CSS - Bird Eats Bug
In this Tailwind CSS tutorial we'll learn about hover classes and how to apply over effects to elements.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks @marktnoonan will explore your answer
Hi, I’m curious about this line:
cy.get('#wrapper-pdf-page-1').trigger('onmouseover')
Shouldn’t that be
trigger('mouseover')
?I think the testing strategy here will depend on how tailwind implements the group hover, if it’s a CSS-only solution depending on
:hover
CSS state, triggering the JS mouse events may not create the actual hover state that Tailwind is looking for. If that’s the source of the problem, common workaround iscy.realHover
using https://github.com/dmtrKovalenko/cypress-real-events.