Skip to content

Commit

Permalink
Add no-drag to Toolbar tooltips in Desktop, open links in default b…
Browse files Browse the repository at this point in the history
…rowser (#3800)

Fixes #3781
  • Loading branch information
franknoirot authored Sep 5, 2024
1 parent e635974 commit 54fb9c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
ToolbarItemResolved,
ToolbarModeName,
} from 'lib/toolbar'
import { isDesktop } from 'lib/isDesktop'
import { openExternalBrowserIfDesktop } from 'lib/openWindow'

export function Toolbar({
className = '',
Expand Down Expand Up @@ -288,6 +290,11 @@ const ToolbarItemTooltip = memo(function ToolbarItemContents({
return (
<Tooltip
inert={false}
wrapperStyle={
isDesktop()
? ({ '-webkit-app-region': 'no-drag' } as React.CSSProperties)
: {}
}
position="bottom"
wrapperClassName="!p-4 !pointer-events-auto"
contentClassName="!text-left text-wrap !text-xs !p-0 !pb-2 flex gap-2 !max-w-none !w-72 flex-col items-stretch"
Expand Down Expand Up @@ -337,6 +344,7 @@ const ToolbarItemTooltip = memo(function ToolbarItemContents({
<li key={link.label} className="contents">
<a
href={link.url}
onClick={openExternalBrowserIfDesktop(link.url)}
target="_blank"
rel="noreferrer"
className="flex items-center rounded-sm p-1 no-underline text-inherit hover:bg-primary/10 hover:text-primary dark:hover:bg-chalkboard-70 dark:hover:text-inherit"
Expand Down
7 changes: 6 additions & 1 deletion src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface TooltipProps extends React.PropsWithChildren {
position?: TooltipPosition
wrapperClassName?: string
contentClassName?: string
wrapperStyle?: React.CSSProperties
delay?: number
hoverOnly?: boolean
inert?: boolean
Expand All @@ -22,6 +23,7 @@ export default function Tooltip({
position = 'top',
wrapperClassName: className,
contentClassName,
wrapperStyle = {},
delay = 200,
hoverOnly = false,
inert = true,
Expand All @@ -36,7 +38,10 @@ export default function Tooltip({
} ${styles.tooltipWrapper} ${hoverOnly ? '' : styles.withFocus} ${
styles[position]
} ${className}`}
style={{ '--_delay': delay + 'ms' } as React.CSSProperties}
style={Object.assign(
{ '--_delay': delay + 'ms' } as React.CSSProperties,
wrapperStyle
)}
>
<div className={`rounded ${styles.tooltip} ${contentClassName || ''}`}>
{children}
Expand Down

0 comments on commit 54fb9c9

Please sign in to comment.