-
Notifications
You must be signed in to change notification settings - Fork 891
feat(desktop): persistent v2 sidebar hover card #3813
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...dSidebar/components/DashboardSidebarHoverCardOverlay/DashboardSidebarHoverCardOverlay.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* Animate the sidebar hover card sliding between rows. Targets the | ||
| * Radix popper wrapper (which carries the position transform) only after | ||
| * it has been placed at its anchor (`data-…="ready"`), so the initial | ||
| * measuring jump from translate(0, -200%) is not animated. */ | ||
| [data-radix-popper-content-wrapper]:has( | ||
| > [data-dashboard-sidebar-hover-card="ready"] | ||
| ) { | ||
| transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1); | ||
| will-change: transform; | ||
| } |
81 changes: 81 additions & 0 deletions
81
...dSidebar/components/DashboardSidebarHoverCardOverlay/DashboardSidebarHoverCardOverlay.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { Popover, PopoverAnchor, PopoverContent } from "@superset/ui/popover"; | ||
| import type { RefObject } from "react"; | ||
| import { useEffect, useRef, useState } from "react"; | ||
| import { useDiffStats } from "renderer/hooks/host-service/useDiffStats"; | ||
| import { useDashboardSidebarHover } from "../../providers/DashboardSidebarHoverProvider"; | ||
| import { DashboardSidebarWorkspaceHoverCardContent } from "../DashboardSidebarWorkspaceItem/components/DashboardSidebarWorkspaceHoverCardContent"; | ||
| import "./DashboardSidebarHoverCardOverlay.css"; | ||
|
|
||
| type Measurable = { getBoundingClientRect(): DOMRect }; | ||
|
|
||
| export function DashboardSidebarHoverCardOverlay({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| const { | ||
| hoveredId, | ||
| anchorElement, | ||
| payload, | ||
| contextMenuOpen, | ||
| cancelClose, | ||
| requestClose, | ||
| forceClose, | ||
| } = useDashboardSidebarHover(); | ||
|
|
||
| const virtualRef = useRef<Measurable | null>(null); | ||
| virtualRef.current = anchorElement; | ||
|
|
||
| const open = hoveredId !== null && payload !== null && !contextMenuOpen; | ||
| const diffStats = useDiffStats(hoveredId ?? ""); | ||
|
|
||
| // Suppress the transform transition until Radix has placed the popover at | ||
| // its real anchor — otherwise the initial jump from the off-screen measuring | ||
| // position (translate(0, -200%)) gets animated. | ||
| const [hasPositioned, setHasPositioned] = useState(false); | ||
| const frameRef = useRef<number | null>(null); | ||
| useEffect(() => { | ||
| if (!open) { | ||
| setHasPositioned(false); | ||
| return; | ||
| } | ||
| const first = requestAnimationFrame(() => { | ||
| frameRef.current = requestAnimationFrame(() => setHasPositioned(true)); | ||
| }); | ||
| frameRef.current = first; | ||
| return () => { | ||
| if (frameRef.current !== null) cancelAnimationFrame(frameRef.current); | ||
| }; | ||
| }, [open]); | ||
|
|
||
| return ( | ||
| <Popover | ||
| open={open} | ||
| onOpenChange={(nextOpen) => { | ||
| if (!nextOpen) forceClose(); | ||
| }} | ||
| > | ||
| {children} | ||
| <PopoverAnchor virtualRef={virtualRef as RefObject<Measurable>} /> | ||
| {payload && ( | ||
| <PopoverContent | ||
| side="right" | ||
| align="start" | ||
| className="w-72" | ||
| data-dashboard-sidebar-hover-card={hasPositioned ? "ready" : ""} | ||
| onOpenAutoFocus={(event) => event.preventDefault()} | ||
| onPointerEnter={cancelClose} | ||
| onPointerLeave={() => { | ||
| if (hoveredId) requestClose(hoveredId); | ||
| }} | ||
| > | ||
| <DashboardSidebarWorkspaceHoverCardContent | ||
| workspace={payload.workspace} | ||
| diffStats={diffStats} | ||
| onEditBranchClick={payload.onEditBranchClick} | ||
| /> | ||
| </PopoverContent> | ||
| )} | ||
| </Popover> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
...ashboard/components/DashboardSidebar/components/DashboardSidebarHoverCardOverlay/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { DashboardSidebarHoverCardOverlay } from "./DashboardSidebarHoverCardOverlay"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If a workspace item unmounts while its hover card is open (e.g., the workspace is closed/deleted remotely while the card is showing),
hoveredIdstays set in the context and the popover remains visible with a detached anchor.getBoundingClientRect()on a detached element returns all-zeros, so the card jumps to the top-left of the screen and stays there until the user moves their mouse.Adding a cleanup effect that calls
hoverRequestClose(id)on unmount prevents this:Prompt To Fix With AI