The hover state of the card component somehow interferes with the z-index ordering. See the following GIF for context:
Here are the classes of the two components:
(I had to simplify the structure in order not to overcomplicate this question. I'm happy to provide more details if needed.)
// Dropdown
<div className='relative h-full w-full' ref={node} onClick={handleMenuClick}>
{/* Menu button */}
{children} // here I render different elements based on where the Dropdown is placed
{/* Dropdown Content */}
// I removed some classes to show only the relevant ones
<div className=`right top ${isMenuOpen ? 'block' : 'hidden'} absolute z-30 rounded`}
onClick={(e) => e.stopPropagation()}>
... // Dropdown content
</div>
</div>
// Card element
<a className='bg-gray-darkest rounded-xl p-8 hover:brightness-75' // note: this is where I'm having issues
href={props.url}>
<img src='...' alt='...'/>
<div className='mt-6'>
<h4 className='font-display text-lg'>{props.name}</h4>
</div>
</a>
I tried to work around it by animating opacity vs brightness or using Tailwind's Groups to animate only some child components inside the card, but the effect is the same. Also removing the hover state and setting a static opacity or brightness value, breaks as well the order of the components.
Thanks for your support!