Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Use Tooltip for buttons

Blue Mouse925c5eee6d53
diff --git a/web/app/components/NotificationChannels/NotificationChannels.tsx b/web/app/components/NotificationChannels/NotificationChannels.tsx
index 540ddbfa1..b6469a570 100644
--- a/web/app/components/NotificationChannels/NotificationChannels.tsx
+++ b/web/app/components/NotificationChannels/NotificationChannels.tsx
@@ -23,6 +23,7 @@ import Input from '~/ui/Input'
import Loader from '~/ui/Loader'
import Modal from '~/ui/Modal'
import { Text } from '~/ui/Text'
+import Tooltip from '~/ui/Tooltip'
import EnableWebPushButton from './EnableWebPushButton'
import { ChannelTypeIcon, summariseConfig } from './utils'
@@ -423,33 +424,51 @@ const NotificationChannels = ({
{t('notificationChannels.verify')}
</Button>
) : null}
- <button
- type='button'
- onClick={() => onTest(channel)}
- disabled={isMutating}
- title={t('notificationChannels.test')}
- className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-100'
- >
- <PaperPlaneTiltIcon className='size-4' aria-hidden />
- </button>
- <button
- type='button'
- onClick={() => onEdit(channel)}
- disabled={isMutating}
- title={t('common.edit')}
- className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-100'
- >
- <PencilSimpleIcon className='size-4' aria-hidden />
- </button>
- <button
- type='button'
- onClick={() => setPendingDelete(channel)}
- disabled={isMutating}
- title={t('common.delete')}
- className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-red-500/10 dark:hover:text-red-400'
- >
- <TrashIcon className='size-4' aria-hidden />
- </button>
+ <Tooltip
+ text={t('notificationChannels.test')}
+ ariaLabel={t('notificationChannels.test')}
+ asChild
+ tooltipNode={
+ <button
+ type='button'
+ onClick={() => onTest(channel)}
+ disabled={isMutating}
+ className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-100'
+ >
+ <PaperPlaneTiltIcon className='size-4' aria-hidden />
+ </button>
+ }
+ />
+ <Tooltip
+ text={t('common.edit')}
+ ariaLabel={t('common.edit')}
+ asChild
+ tooltipNode={
+ <button
+ type='button'
+ onClick={() => onEdit(channel)}
+ disabled={isMutating}
+ className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-100'
+ >
+ <PencilSimpleIcon className='size-4' aria-hidden />
+ </button>
+ }
+ />
+ <Tooltip
+ text={t('common.delete')}
+ ariaLabel={t('common.delete')}
+ asChild
+ tooltipNode={
+ <button
+ type='button'
+ onClick={() => setPendingDelete(channel)}
+ disabled={isMutating}
+ className='inline-flex size-8 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-red-50 hover:text-red-600 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-red-500/10 dark:hover:text-red-400'
+ >
+ <TrashIcon className='size-4' aria-hidden />
+ </button>
+ }
+ />
</div>
</li>
)
diff --git a/web/app/ui/Tooltip.tsx b/web/app/ui/Tooltip.tsx
index fb7c2903d..07adf26ac 100644
--- a/web/app/ui/Tooltip.tsx
+++ b/web/app/ui/Tooltip.tsx
@@ -34,6 +34,8 @@ interface TooltipProps {
text: string | number | React.ReactNode
className?: string
tooltipNode?: React.ReactNode
+ ariaLabel?: string
+ asChild?: boolean
delay?: number
/**
* When true, the tooltip content won't capture hover events,
@@ -46,10 +48,13 @@ const Tooltip = ({
text,
className,
tooltipNode,
+ ariaLabel,
+ asChild,
delay = 50,
disableHoverableContent,
}: TooltipProps) => {
const { t } = useTranslation()
+ const triggerAriaLabel = ariaLabel || t('common.learnMore')
return (
<TooltipProvider
@@ -58,8 +63,9 @@ const Tooltip = ({
>
<TooltipRoot>
<TooltipTrigger
+ asChild={asChild}
className={className}
- aria-label={t('common.learnMore')}
+ aria-label={triggerAriaLabel}
>
{tooltipNode || (
<QuestionIcon className='size-4.5 fill-slate-700 stroke-gray-50 dark:fill-slate-200 dark:stroke-slate-800' />