-
-
Notifications
You must be signed in to change notification settings - Fork 344
[preview card] Support nested preview cards #3798
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
base: master
Are you sure you want to change the base?
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
a20e824 to
fabe248
Compare
Greptile SummaryThis PR successfully implements support for nested preview cards by integrating Key changes:
The implementation correctly addresses the issue where hovering through nested preview cards would close parent cards. The safePolygon handler's logic (lines 147-153 in Confidence Score: 4/5
Important Files Changed
|
packages/react/src/floating-ui-react/hooks/useHoverFloatingInteraction.ts
Outdated
Show resolved
Hide resolved
| // The handler needs to remain active to detect when mouse leaves to | ||
| // a nested portaled popup. The safePolygon logic checks for open children | ||
| // in the floating tree and prevents closing when appropriate. | ||
| handlerRef.current?.(event); |
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.
@atomiks I think this fixes the problem.
If we clean the mouse move events when opening the nested popover / preview card, then safePolygon can't properly do its job.
Tbh I don't know the codebase enough yet to be fully confident of the fix.
My experiment of both the nested Popover AND the nested Preview Card now work at least.
And without introducing additional logic that safePolygon should already handle.
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.
Yeah that looks to be a difference between the two hooks.
useHover
function onFloatingMouseEnter() {
timeout.clear();
clearPointerEvents();
}useHoverFloatingInteraction
function onFloatingMouseEnter(event: MouseEvent) {
openChangeTimeout.clear();
clearPointerEvents();
handlerRef.current?.(event);
cleanupMouseMoveHandler();
}Though the old one still doesn't call handlerRef.current
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.
I don't get any failing test and the nested popover and preview cards still behavior correctly if I comment the handlerRef.current?.(event); line.
But that's a change that could easily not be covered by any test.
cc @michaldudak since you did the initial useHoverFloatingInteraction implementation
Atempt to fix #3673
The hardest part was to now close the root Preview Card when hovering through its children Preview Card