-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: checkpoint restore popover positioning issue (#8219) #8220
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
Conversation
Fixes issue where the checkpoint restore popover would misposition when the mouse moved from the CheckpointSaved component to the popover itself. The menu now remains visible while the popover is open, preventing the anchor element from disappearing. Fixes #8219
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.
Reviewing my own code feels like debugging in a mirror - everything looks backwards but somehow still broken.
export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps) => { | ||
const { t } = useTranslation() | ||
const isCurrent = props.currentHash === props.commitHash | ||
const [isPopoverOpen, setIsPopoverOpen] = useState(false) |
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.
Missing test coverage: Consider adding tests for this component, especially to verify the popover positioning fix and state management behavior. This would help prevent regression of the positioning bug.
onOpenChange={(open) => { | ||
setIsOpen(open) | ||
setIsConfirming(false) | ||
onPopoverOpenChange?.(open) |
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.
Potential optimization: While the current implementation works well, consider memoizing the callback in the parent component if this component gets re-rendered frequently to avoid unnecessary re-renders.
|
||
<div className="hidden group-hover:block h-4 -mt-2"> | ||
<CheckpointMenu {...props} checkpoint={metadata} /> | ||
<div className={`h-4 -mt-2 ${isPopoverOpen ? "block" : "hidden group-hover:block"}`}> |
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.
Minor suggestion: For better semantic clarity, consider using a data attribute approach like instead of the ternary operator for class toggling. This would make the intent more explicit:
… add focused test for visibility logic (#8220)
…heckpointSaved component
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.
LGTM
Description
This PR fixes the checkpoint restore popover positioning issue where the popover would misplace when the mouse moved from the CheckpointSaved component to the popover itself.
Problem
The CheckpointMenu was only visible on hover (using
hidden group-hover:block
). When users moved their mouse to interact with the popover, they would leave the hover area of the parent group, causing the CheckpointMenu to hide and the popover to lose its anchor element, resulting in incorrect positioning.Solution
Added state tracking to maintain menu visibility when the popover is open:
isPopoverOpen
state in CheckpointSaved componentonPopoverOpenChange
callback prop to CheckpointMenuChanges
Testing
Fixes #8219
Important
Fixes popover positioning in
CheckpointSaved
by managing menu visibility with new state and callback, ensuring correct interaction behavior.CheckpointSaved
by maintaining menu visibility when popover is open.isPopoverOpen
state andonPopoverOpenChange
callback inCheckpointSaved
.CheckpointMenu
to handle controlled and uncontrolled popover states.CheckpointSaved.spec.tsx
to test popover visibility and confirm state reset.CheckpointMenu
to useopen
andonOpenChange
props for popover control.This description was created by
for 51059b9. You can customize this summary. It will automatically update as commits are pushed.