Skip to content

Commit

Permalink
Fix: Tooltip Not Appearing for "Add Section Title" (#144)
Browse files Browse the repository at this point in the history
# [SRBT-349] Fix: Tooltip Not Appearing for "Add Section Title"

**Changes**

- Refactored the SectionTitleIcon to be wrapped in a `div` instead of an
`svg`. I also refactored the Tooltip Trigger for section titles to be a
button. Apparently, Tooltips can only to appear on
[buttons](radix-ui/primitives#955 (comment)),
or elements that require a click / pointer-down interaction – from what
I've gathered on the documentation beyond this specific GitHub issue.

# Screenshots

<img width="487" alt="Screenshot 2024-12-03 at 8 57 21 AM"
src="https://github.com/user-attachments/assets/a1a38d3f-075c-46b7-9064-a0b581efcf5a">

---------

Co-authored-by: Audrey Ostrom <[email protected]>
  • Loading branch information
audreyostrom and audsostrom authored Dec 5, 2024
1 parent a43eec7 commit cd56268
Showing 1 changed file with 57 additions and 55 deletions.
112 changes: 57 additions & 55 deletions src/components/profile/widgets/add-widgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,24 @@ export const AddWidgets: React.FC<AddWidgetsProps> = ({
</div>

<div className='flex items-center gap-2'>
<TooltipProvider>
{featureFlags.sectionTitles && (
{featureFlags.sectionTitles && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<SectionTitleIcon
<Button
variant='ghost'
className='h-fit p-0'
onClick={addSectionTitle}
className='hover:text-sorbet'
width={20}
height={20}
/>
disabled={loading}
>
<SectionTitleIcon className='hover:text-sorbet size-5' />
</Button>
</TooltipTrigger>
<TooltipContent>Add section title</TooltipContent>
</Tooltip>
)}
</TooltipProvider>
)}
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<label
Expand Down Expand Up @@ -247,55 +251,53 @@ export const AddWidgets: React.FC<AddWidgetsProps> = ({

/** Local component for achieving purple effect on a custom icon */
interface SectionTitleIconProps {
onClick?: () => void;
className?: string;
width?: number | string; // Allow dynamic width
height?: number | string; // Allow dynamic height
}
const SectionTitleIcon: React.FC<SectionTitleIconProps> = ({
onClick,
className,
width = 20,
height = 20,
}) => {
const SectionTitleIcon: React.FC<SectionTitleIconProps> = ({ className }) => {
return (
<svg
onClick={onClick}
width={width}
height={height}
viewBox='0 0 20 20'
fill='none'
xmlns='http://www.w3.org/2000/svg'
className={`group cursor-pointer transition-colors ${className}`}
>
<rect
x='1'
y='1'
width='18'
height='18'
rx='3'
stroke='currentColor'
strokeWidth='2'
/>
<rect x='3.5' y='4.75' width='10' height='2' rx='1' fill='currentColor' />
<rect
x='3.5'
y='9.25'
width='6'
height='6'
rx='2'
fill='#A8A8A8'
className='group-hover:fill-current'
/>
<rect
x='10.5'
y='9.25'
width='6'
height='6'
rx='2'
fill='#A8A8A8'
className='group-hover:fill-current'
/>
</svg>
<div>
<svg
viewBox='0 0 20 20'
fill='none'
xmlns='http://www.w3.org/2000/svg'
className={`group cursor-pointer transition-colors ${className}`}
>
<rect
x='1'
y='1'
width='18'
height='18'
rx='3'
stroke='currentColor'
strokeWidth='2'
/>
<rect
x='3.5'
y='4.75'
width='10'
height='2'
rx='1'
fill='currentColor'
/>
<rect
x='3.5'
y='9.25'
width='6'
height='6'
rx='2'
fill='#A8A8A8'
className='group-hover:fill-current'
/>
<rect
x='10.5'
y='9.25'
width='6'
height='6'
rx='2'
fill='#A8A8A8'
className='group-hover:fill-current'
/>
</svg>
</div>
);
};

0 comments on commit cd56268

Please sign in to comment.