-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
enhance HoverCard component with group delay logic #7890
Conversation
…ys across multiple HoverCards"
…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.
There was a problem hiding this 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 multipleHoverCard
instances respect the group delays.
export function HoverCardGroup(props: HoverCardGroupProps) {
window.clearTimeout(closeTimeout.current); | ||
}, []); | ||
|
||
const onChange = useCallback( |
There was a problem hiding this comment.
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.
packages/@mantine/core/src/components/HoverCard/use-hover-card.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Thanks! |
Summary
This pull request introduces improvements to the
HoverCard
component:HoverCard
to simplify group handling and centralize delay logic using theuse-hover-card
hook.HoverCard.Group
to synchronize open/close delays across multipleHoverCard
components.