Skip to content

enhance HoverCard component with group delay logic #7890

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

Han5991
Copy link
Contributor

@Han5991 Han5991 commented May 25, 2025

Summary

This pull request introduces improvements to the HoverCard component:

  • Refactored HoverCard to simplify group handling and centralize delay logic using the use-hover-card hook.
  • Added HoverCard.Group to synchronize open/close delays across multiple HoverCard components.
  • Updated demo examples to showcase the new group functionality and delay timing.
  • Performed minor cleanups, including import consistency, removal of unused code, and compliance with formatting standards.

Han5991 added 2 commits May 25, 2025 20:59
…agement

- Removed legacy implementation and comments in `HoverCard` components.
- Centralized `openDropdown` and `closeDropdown` delay logic in `use-hover-card` hook with timeouts managed via `useRef`.
- Adjusted group-aware hover behavior to remove redundancy.
- Updated demo to showcase modified delay timing for `HoverCard.Group`.
- Minor cleanup: consistent imports, removed unused code, and ensured file formatting compliance.
@rtivital rtivital requested a review from Copilot May 26, 2025 06:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the HoverCard component to centralize its delay logic into a new useHoverCard hook, introduces a HoverCard.Group wrapper for synchronized open/close delays, and updates all related exports, stories, demos, and documentation to support the new grouping feature.

  • Centralized hover delay and open/close logic in use-hover-card.ts
  • Added HoverCard.Group component with context and floating delay group
  • Updated exports, stories, demos, and docs to showcase and support the group behavior

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/@mantine/core/src/components/HoverCard/use-hover-card.ts Extracted delay handling into useHoverCard hook
packages/@mantine/core/src/components/HoverCard/index.ts Exported HoverCardGroup and its prop types
packages/@mantine/core/src/components/HoverCard/HoverCardTarget/HoverCardTarget.tsx Enhanced target to respect group context
packages/@mantine/core/src/components/HoverCard/HoverCardDropdown/HoverCardDropdown.tsx Enhanced dropdown to respect group context
packages/@mantine/core/src/components/HoverCard/HoverCard.tsx Integrated useHoverCard and added HoverCard.Group
packages/@mantine/core/src/components/HoverCard/HoverCard.context.ts Extended context shape for group support
packages/@mantine/core/src/components/HoverCard/HoverCardGroup/HoverCardGroup.tsx New HoverCard.Group component implementation
packages/@mantine/core/src/components/HoverCard/HoverCardGroup/HoverCardGroup.context.ts New context for group mode flag
packages/@docs/demos/src/demos/core/HoverCard/index.ts Added group demo export
packages/@docs/demos/src/demos/core/HoverCard/HoverCard.demos.story.tsx Registered Demo_group story
packages/@docs/demos/src/demos/core/HoverCard/HoverCard.demo.group.tsx New group demo code
apps/mantine.dev/src/pages/core/hover-card.mdx Documentation section for HoverCard.Group
Comments suppressed due to low confidence (1)

packages/@mantine/core/src/components/HoverCard/HoverCardGroup/HoverCardGroup.tsx:21

  • The new HoverCard.Group synchronization logic isn’t covered by any tests. It would be valuable to add unit or integration tests to verify that multiple HoverCard instances respect the group delays.
export function HoverCardGroup(props: HoverCardGroupProps) {

window.clearTimeout(closeTimeout.current);
}, []);

const onChange = useCallback(
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onChange callback uses setCurrentId but it isn’t listed in the dependency array. Please include setCurrentId to ensure the callback always has the latest reference.

Copilot uses AI. Check for mistakes.

@rtivital rtivital changed the base branch from master to 8.2.0-contributions May 26, 2025 06:17
@rtivital rtivital merged commit 66ae907 into mantinedev:8.2.0-contributions May 27, 2025
1 check passed
@rtivital
Copy link
Member

Thanks!

@Han5991 Han5991 deleted the feature/delay-hover-card branch June 22, 2025 10:00
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