Repository navigation
fix: Show full text on hover when text overflows the cards on the list page. - #16787
Conversation
📝 WalkthroughWalkthroughA new ChangesTruncatedText Component and HomeCard Integration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant HomeCard
participant TruncatedText
participant Tooltip
HomeCard->>TruncatedText: render with tooltip=data.name/data.description
TruncatedText->>TruncatedText: measure scrollWidth vs clientWidth
alt text truncated
TruncatedText->>Tooltip: wrap content, set open state
Tooltip-->>HomeCard: show tooltip on hover
else not truncated
TruncatedText-->>HomeCard: render Tag only
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/src/components/home-card.tsx (1)
60-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the
onOpenChangehandler to comply with coding guidelines.The inline arrow function in
onOpenChangeviolates the project guideline: "Avoid inline event handlers in JSX; define handlers separately and pass references such asonClick={handleClick}instead of inline arrows." As per coding guidelines, inline event handlers in JSX should be avoided.♻️ Proposed refactor
function TruncatedText({ as: Tag = 'div', className, children, tooltip, testId, }: { as?: ElementType; className?: string; children?: ReactNode; tooltip?: ReactNode; testId?: string; }) { const ref = useRef<HTMLElement>(null); const [open, setOpen] = useState(false); + const handleOpenChange = (next: boolean) => { + const el = ref.current; + setOpen(next && el !== null && el.scrollWidth > el.clientWidth); + }; if (tooltip == null) { return ( <Tag ref={ref} className={className} data-testid={testId}> {children} </Tag> ); } return ( <Tooltip open={open} - onOpenChange={(next) => { - const el = ref.current; - setOpen(next && el !== null && el.scrollWidth > el.clientWidth); - }} + onOpenChange={handleOpenChange} > <TooltipTrigger asChild> <Tag ref={ref} className={className} data-testid={testId}> {children} </Tag> </TooltipTrigger> <TooltipContent>{tooltip}</TooltipContent> </Tooltip> ); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/components/home-card.tsx` around lines 60 - 63, The inline onOpenChange arrow in home-card.tsx should be extracted to a named handler to match the JSX event-handler guideline. Move the current logic that reads ref.current and calls setOpen into a separate function in the HomeCard component (for example, a handleOpenChange-style method), then pass that function reference to onOpenChange instead of defining the arrow inline.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/home-card.tsx`:
- Around line 46-72: The tooltip trigger in HomeCard is not keyboard-focusable
because the rendered Tag element is not naturally focusable, so keyboard users
cannot open the tooltip. Update the HomeCard component around TooltipTrigger/Tag
so that when tooltip is provided the trigger can receive focus (for example by
adding focusability to the Tag used as the TooltipTrigger), while keeping the
existing open state and truncation check logic in place.
---
Nitpick comments:
In `@web/src/components/home-card.tsx`:
- Around line 60-63: The inline onOpenChange arrow in home-card.tsx should be
extracted to a named handler to match the JSX event-handler guideline. Move the
current logic that reads ref.current and calls setOpen into a separate function
in the HomeCard component (for example, a handleOpenChange-style method), then
pass that function reference to onOpenChange instead of defining the arrow
inline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 94dcb4fb-0d08-4e05-aee2-1df1427af96d
📒 Files selected for processing (1)
web/src/components/home-card.tsx
Summary
fix: Show full text on hover when text overflows the cards on the list page.