Skip to content

[@mantine/core] HoverCard: Fix dropdown closing when clicked #8097

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

Merged

Conversation

ikapta
Copy link
Contributor

@ikapta ikapta commented Jul 22, 2025

HoverCard Dropdown Issue and Proposed Fix

Issue Description

The HoverCard dropdown closes unexpectedly when clicked, disrupting the user experience as it should remain open during interaction.

Root Cause

The issue occurs because floating-ui's useDismiss hook incorrectly triggers an outside click event, calling onChange(false) to close the dropdown. The useHoverCard hook's inner useFloating is only intended for withinGroup contexts, so useDismiss should only be active when withinGroup is enabled. However, useDismiss is triggered regardless of this state. Additionally, useDismiss checks if the dropdown is open before registering events internally, but the condition enabled: typeof settings.opened === 'undefined' maybe incorrect, leading to improper event registration.

Proposed Fix

A small update is needed to ensure useDismiss is only active when withinGroup is enabled, preventing the dropdown from closing unexpectedly outside this context, and works like before. Additionally, the enabled check in useDismiss should be corrected to properly handle click-outside events, ensuring events are only registered when the dropdown is open and within the withinGroup context.

@rtivital rtivital merged commit 6979187 into mantinedev:master Jul 23, 2025
1 check passed
@rtivital
Copy link
Member

Thanks!

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.

2 participants