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

fix(a11y): clip sr-only data tables with a wrapper div (#2103)

The visually-hidden performance and WAN traffic tables put sr-only on the
table element itself. A table treats height as a minimum (CSS 2.1 17.5.3)
and overflow does not clip table layout, so the absolutely-positioned box
still grew to its full content height and stretched the document scroll
height. On a long series this added hundreds of pixels of dead overscroll
below the page, visible as a blank band in the light theme.

Move sr-only onto a wrapper div and leave the table unstyled inside it.
The div clips to 1x1 with overflow:hidden regardless of row count, while
the table stays in the accessibility tree for screen readers. The caption
span is unchanged.

Reproduced headless in #2087: sr-only on the table gave scrollHeight 4496
for a 98-row series, the wrapper gave 2843 (same as no table). Confirmed on
a live fleet with the before and after captures posted in that thread.

Scope is the two components named in review, WanTraffic and
RouterPerformance. The column weight pass stays in #2087.
Bann-DEV 2 недель назад
Родитель
Сommit
bc31c06e29
2 измененных файлов с 30 добавлено и 20 удалено
  1. 14 10
      app/src/components/routers/RouterPerformance.tsx
  2. 16 10
      app/src/sections/WanTraffic.tsx

+ 14 - 10
app/src/components/routers/RouterPerformance.tsx

@@ -170,16 +170,20 @@ export function RouterPerformance({ router, liveSeries, totalRamMb, usedRamMb }:
       {/* Descripción + tabla accesible (visually-hidden). El texto va en un
           span sr-only: <caption> escapa del clip del table sr-only (#63). */}
       <span className="sr-only">{t('routerDetail.perf.tableCaption', { range })}</span>
-      <table className="sr-only">
-        <thead>
-          <tr><th>{t('home.traffic.time')}</th><th>CPU (%)</th><th>{t('common.memory')} (%)</th><th>{t('common.temperature')} ({tempUnitSymbol(tempUnit)})</th></tr>
-        </thead>
-        <tbody>
-          {data.map((p: PerfPoint) => (
-            <tr key={p.t}><td>{p.t}</td><td>{p.cpu}</td><td>{p.ram}</td><td>{p.temp}</td></tr>
-          ))}
-        </tbody>
-      </table>
+      {/* sr-only on a wrapper div, not the table (see WanTraffic): a table
+          ignores height:1px and its box stretched the document scroll height. */}
+      <div className="sr-only">
+        <table>
+          <thead>
+            <tr><th>{t('home.traffic.time')}</th><th>CPU (%)</th><th>{t('common.memory')} (%)</th><th>{t('common.temperature')} ({tempUnitSymbol(tempUnit)})</th></tr>
+          </thead>
+          <tbody>
+            {data.map((p: PerfPoint) => (
+              <tr key={p.t}><td>{p.t}</td><td>{p.cpu}</td><td>{p.ram}</td><td>{p.temp}</td></tr>
+            ))}
+          </tbody>
+        </table>
+      </div>
     </section>
   )
 }

+ 16 - 10
app/src/sections/WanTraffic.tsx

@@ -271,16 +271,22 @@ export function WanTraffic() {
           span sr-only porque <caption> escapa del clip del table sr-only
           (display: table-caption) y quedaría visible encima del header (#63). */}
       <span className="sr-only">{t('home.traffic.tableCaption', { range })}</span>
-      <table className="sr-only">
-        <thead>
-          <tr><th>{t('home.traffic.time')}</th><th>{t('home.traffic.downloadMbps')}</th><th>{t('home.traffic.uploadMbps')}</th></tr>
-        </thead>
-        <tbody>
-          {liveData.map((p) => (
-            <tr key={p.t}><td>{p.t}</td><td>{p.down}</td><td>{p.up}</td></tr>
-          ))}
-        </tbody>
-      </table>
+      {/* sr-only on a wrapper div, not the table: a table grows to its content
+          height even at height:1px, and clip-path hides paint but not the box,
+          so an sr-only table stretched the document scroll height. The div
+          clips to 1x1 with overflow:hidden. */}
+      <div className="sr-only">
+        <table>
+          <thead>
+            <tr><th>{t('home.traffic.time')}</th><th>{t('home.traffic.downloadMbps')}</th><th>{t('home.traffic.uploadMbps')}</th></tr>
+          </thead>
+          <tbody>
+            {liveData.map((p) => (
+              <tr key={p.t}><td>{p.t}</td><td>{p.down}</td><td>{p.up}</td></tr>
+            ))}
+          </tbody>
+        </table>
+      </div>
 
       <div className="mt-4 grid grid-cols-2 gap-3 border-t border-border pt-4 sm:grid-cols-4">
         {FOOTER_METRICS.map((m, i) => (