question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tailwind hidden class but change on group-hover

See original GitHub issue

Current 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:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hilmanskicommented, Nov 9, 2022

thanks @marktnoonan will explore your answer

0reactions
marktnoonancommented, Nov 9, 2022

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 is cy.realHover using https://github.com/dmtrKovalenko/cypress-real-events.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found