Просмотр исходного кода

fix(alerts): always-visible row actions with labels on touch devices (#862) (#873)

Touch devices have no hover, so the alert row actions (identify, update agent, dismiss, silence) were invisible and unreachable. On coarse pointers the actions now show always with their text label and a larger hit area, and the action cluster wraps onto its own line so the alert title keeps its full width. Desktop behavior is unchanged. Verified with Playwright touch emulation on the demo dataset. Closes #862
Nacho 2 месяцев назад
Родитель
Сommit
7345d439a4
3 измененных файлов с 11 добавлено и 10 удалено
  1. 2 2
      app/src/components/AlertItem.tsx
  2. 6 5
      app/src/components/RowAction.tsx
  3. 3 3
      app/src/pages/Alerts.tsx

+ 2 - 2
app/src/components/AlertItem.tsx

@@ -74,9 +74,9 @@ export function AlertItem({ alert, onClick, onDismiss, className }: AlertItemPro
         <Icon className="h-[18px] w-[18px]" strokeWidth={1.75} />
       </div>
       <div className="min-w-0 flex-1">
-        <div className="flex items-center justify-between gap-2">
+        <div className="flex items-center justify-between gap-2 pointer-coarse:flex-wrap">
           <span className="truncate text-sm font-medium text-text-primary">{alertTitle(t, alert)}</span>
-          <span className="flex shrink-0 items-center gap-1">
+          <span className="flex shrink-0 items-center gap-1 pointer-coarse:basis-full">
             {action && (
               <RowAction
                 icon={action.icon}

+ 6 - 5
app/src/components/RowAction.tsx

@@ -5,9 +5,10 @@ import { cn } from '@/lib/utils'
 // #862: acción de fila con icono grande y etiqueta de texto que aparece con
 // el hover de la FILA (no solo del icono). La etiqueta reserva su espacio con
 // una transición max-width, así no empuja el resto del contenido de la fila.
-// En pantallas estrechas (<sm) queda solo el icono (el hover de fila apenas
-// existe en táctil; ver issue aparte de coarse pointers). Compartida por el
-// feed (Alerts.tsx) y el resumen (AlertItem.tsx).
+// En pantallas estrechas (<sm) queda solo el icono. En táctil (pointer:
+// coarse) no existe hover: acción e etiqueta se muestran SIEMPRE y con área
+// de clic mayor (#862 parte táctil). Compartida por el feed (Alerts.tsx) y el
+// resumen (AlertItem.tsx).
 export function RowAction({
   icon: Icon,
   label,
@@ -26,13 +27,13 @@ export function RowAction({
       type="button"
       onClick={onClick}
       className={cn(
-        'flex items-center gap-1 rounded-md px-1.5 py-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100',
+        'flex items-center gap-1 rounded-md px-1.5 py-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 pointer-coarse:opacity-100 pointer-coarse:px-2.5 pointer-coarse:py-2',
         className,
       )}
       title={title}
     >
       <Icon className="h-4 w-4 shrink-0" strokeWidth={1.75} />
-      <span className="hidden max-w-0 overflow-hidden whitespace-nowrap text-caption opacity-0 transition-all duration-200 group-hover:opacity-100 sm:inline-block sm:group-hover:max-w-40">
+      <span className="hidden max-w-0 overflow-hidden whitespace-nowrap text-caption opacity-0 transition-all duration-200 group-hover:opacity-100 sm:inline-block sm:group-hover:max-w-40 pointer-coarse:inline-block pointer-coarse:max-w-40 pointer-coarse:opacity-100">
         {label}
       </span>
     </button>

+ 3 - 3
app/src/pages/Alerts.tsx

@@ -327,7 +327,7 @@ function FeedRow({ ev, index, read, expanded, onToggle, reduce, onSilence, onDis
         )}
       >
         <div className="min-w-0 flex-1">
-          <div className="flex items-center justify-between gap-2">
+          <div className="flex items-center justify-between gap-2 pointer-coarse:flex-wrap">
             <span className="flex min-w-0 items-center gap-2">
               <span className="truncate text-sm font-medium text-text-primary">{alertTitle(t, ev)}</span>
               {ev.urgent && (
@@ -336,7 +336,7 @@ function FeedRow({ ev, index, read, expanded, onToggle, reduce, onSilence, onDis
                 </span>
               )}
             </span>
-            <span className="flex shrink-0 items-center gap-2">
+            <span className="flex shrink-0 items-center gap-2 pointer-coarse:basis-full">
               <AnimatePresence initial={false}>
                 {!read && (
                   <motion.span
@@ -352,7 +352,7 @@ function FeedRow({ ev, index, read, expanded, onToggle, reduce, onSilence, onDis
                 <button
                   type="button"
                   onClick={(e) => { e.stopPropagation(); setShowSilence((v) => !v) }}
-                  className="rounded-md p-1 opacity-0 group-hover:opacity-100 transition-opacity text-text-muted hover:text-text-primary"
+                  className="rounded-md p-1 opacity-0 group-hover:opacity-100 transition-opacity text-text-muted hover:text-text-primary pointer-coarse:opacity-100 pointer-coarse:p-2"
                   title={t('alerts.silence')}
                 >
                   <BellOff className="h-4 w-4" strokeWidth={1.75} />