Yuchen Yuan Claude Opus 4.7 (1M context) commited on
Commit
524287c
·
1 Parent(s): 725a720

Mobile + a11y + defense-in-depth fixes from broader audit

Browse files

Mobile + keyboard access to palette tiles (CRITICAL)

Previously the only way to add a block to the canvas was HTML5 drag-
and-drop, which doesn't fire on touch devices and has no keyboard
analogue. Tiles were <div draggable> with no role, no tabIndex, and
no click handler — so mobile users could only use the BlockPicker
dropdown, and keyboard users had no path at all.

- PaletteTile is now a <button type="button"> with onClick →
addBlocksToCanvas([kind]) plus a Space override (Enter is handled
by the native button semantics).
- Drag-and-drop still works for mouse users on top of this — the
button element preserves draggable + onDragStart so drag-to-
insert keeps working.
- focus-visible:ring-2 ring-accent makes the focused tile obvious to
keyboard users.
- aria-label per tile now reads "Add Gate Counter block to canvas.
Tally gate types in the current circuit." (label + tagline) rather
than relying on title-attr-only.

Touch-friendly delete X (IMPORTANT)

Both the palette plugin delete X and the canvas QNode delete X were
opacity-0 group-hover:opacity-100 — invisible on touch (no hover
state on phones) AND unreachable for keyboard users (would need
hover to find). Now opacity-70 at rest and 100% on hover or keyboard
focus, with the button bumped to 20px (palette) / 24px (canvas) for
easier tapping. Discoverability win without visual clutter.

Defense-in-depth SVG isolation (CRITICAL)

The backend's _scrub_figures rejects <script>, on*= attrs,
foreignObject, javascript: URLs, etc. SvgBlock previously rendered
via dangerouslySetInnerHTML — fine because the scrubber holds, but a
stage-2 bypass (CSS injection, future SVG attack vectors, inherited
page styles) could still touch our DOM, cookies, or origin.

SvgBlock now renders inside an iframe with sandbox="" — no
allow-scripts, no allow-same-origin. Even if a future attack vector
gets SVG to execute JS, that JS lives in a null-origin sandbox with
no access to the parent. The srcdoc shell includes minimal CSS to
keep the rendered SVG responsive within the card.

Bar chart improvements (IMPORTANT)

- Meaningful aria-label generated from the dataset: "Bar chart of N
values. Maximum: V at 'label'." Previously hard-coded "Bar chart"
told screen readers nothing.
- Geometry: min bar width 14px always honored. Past N=18 or so the
chart grows wider than the card; the outer wrapper now scrolls
horizontally instead of squashing labels to unreadable pixel sizes.

Focus return on modal close (IMPORTANT)

UploadPluginModal and AuthButton dropdown now remember the element
that had focus when they opened, and restore it on close. Without
this, Escape-closing the modal stranded keyboard users at the top
of the document.

prefers-reduced-motion (IMPORTANT)

Global CSS rule disables long-running animations (the React Flow
edge stroke-dash loop, spinners, pulses) when the OS reports
prefers-reduced-motion: reduce. Transitions stay nearly-instant so
the UI still feels responsive without continuous motion. Edge
dasharray is force-cleared so animated edges go static.

Developers popover (user request)

Yuchen Yuan is now first in the Developers popover row, with both
the personal site link and a new LinkedIn link displayed as side-
by-side chips. Person interface gained optional secondaryUrl +
secondaryLabel fields so future contributors with multiple links
extend cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

frontend/src/components/AuthButton.tsx CHANGED
@@ -21,6 +21,21 @@ export function AuthButton({ mobile = false }: { mobile?: boolean } = {}) {
21
  const setPlugins = useApp((s) => s.setPlugins);
22
  const [menuOpen, setMenuOpen] = useState(false);
23
  const wrapRef = useRef<HTMLDivElement | null>(null);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  // Click-outside + Escape close the dropdown.
26
  useEffect(() => {
@@ -99,6 +114,7 @@ export function AuthButton({ mobile = false }: { mobile?: boolean } = {}) {
99
  return (
100
  <div className="relative" ref={wrapRef}>
101
  <button
 
102
  type="button"
103
  onClick={() => setMenuOpen((v) => !v)}
104
  className="flex items-center gap-1.5 px-2 py-1 rounded-md border border-edge bg-surface/60 text-mute hover:text-ink hover:border-accent/40 text-xs"
 
21
  const setPlugins = useApp((s) => s.setPlugins);
22
  const [menuOpen, setMenuOpen] = useState(false);
23
  const wrapRef = useRef<HTMLDivElement | null>(null);
24
+ const triggerRef = useRef<HTMLButtonElement | null>(null);
25
+
26
+ // When the dropdown closes (via Escape, click-outside, or explicit
27
+ // close), return focus to the trigger so keyboard users can keep
28
+ // navigating from where they were.
29
+ useEffect(() => {
30
+ if (!menuOpen && triggerRef.current && document.activeElement) {
31
+ // Only restore focus when something inside us had focus —
32
+ // otherwise we'd steal focus from elsewhere on a programmatic
33
+ // close.
34
+ if (wrapRef.current?.contains(document.activeElement)) {
35
+ triggerRef.current.focus();
36
+ }
37
+ }
38
+ }, [menuOpen]);
39
 
40
  // Click-outside + Escape close the dropdown.
41
  useEffect(() => {
 
114
  return (
115
  <div className="relative" ref={wrapRef}>
116
  <button
117
+ ref={triggerRef}
118
  type="button"
119
  onClick={() => setMenuOpen((v) => !v)}
120
  className="flex items-center gap-1.5 px-2 py-1 rounded-md border border-edge bg-surface/60 text-mute hover:text-ink hover:border-accent/40 text-xs"
frontend/src/components/DevelopersPopover.tsx CHANGED
@@ -16,22 +16,27 @@ import { CircleUser, ExternalLink } from "lucide-react";
16
 
17
  interface Person {
18
  name: string;
19
- /** Where the "open" click takes the user. */
20
  url: string;
21
  /** Domain/platform label shown as a right-aligned footer chip. */
22
  linkLabel: string;
 
 
 
23
  }
24
 
25
  const PEOPLE: Person[] = [
26
- {
27
- name: "Jovin Antony Maria",
28
- url: "https://www.linkedin.com/in/jovin-antony-maria-987262348/",
29
- linkLabel: "LinkedIn",
30
- },
31
  {
32
  name: "Yuchen Yuan",
33
  url: "https://theyuchen.github.io/",
34
  linkLabel: "theyuchen.github.io",
 
 
 
 
 
 
 
35
  },
36
  ];
37
 
@@ -80,24 +85,42 @@ export function DevelopersPopover() {
80
  className="fixed right-3 top-14 sm:absolute sm:right-0 sm:top-full sm:mt-1 rounded-lg border border-edge bg-surface shadow-xl z-40 p-2 flex flex-col gap-0.5 w-[min(20rem,calc(100vw-1.5rem))]"
81
  >
82
  {PEOPLE.map((p) => (
83
- <a
84
  key={p.name}
85
  role="menuitem"
86
- href={p.url}
87
- target="_blank"
88
- rel="noopener noreferrer"
89
- onClick={() => setOpen(false)}
90
  className="px-3 py-2 rounded-md hover:bg-surfaceAlt transition-colors border border-transparent hover:border-edge/60 flex items-center gap-3"
91
  >
92
  <CircleUser className="w-4 h-4 text-mute shrink-0" />
93
  <span className="flex-1 min-w-0 text-sm text-ink font-medium truncate">
94
  {p.name}
95
  </span>
96
- <span className="flex items-center gap-1 text-[10px] text-mute font-mono shrink-0">
97
- {p.linkLabel}
98
- <ExternalLink className="w-3 h-3" />
99
- </span>
100
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  ))}
102
  </div>
103
  )}
 
16
 
17
  interface Person {
18
  name: string;
19
+ /** Where the "open" click takes the user (primary link). */
20
  url: string;
21
  /** Domain/platform label shown as a right-aligned footer chip. */
22
  linkLabel: string;
23
+ /** Optional second link shown as a small chip alongside the first. */
24
+ secondaryUrl?: string;
25
+ secondaryLabel?: string;
26
  }
27
 
28
  const PEOPLE: Person[] = [
 
 
 
 
 
29
  {
30
  name: "Yuchen Yuan",
31
  url: "https://theyuchen.github.io/",
32
  linkLabel: "theyuchen.github.io",
33
+ secondaryUrl: "https://www.linkedin.com/in/yuchen-ethan-yuan-851130378/",
34
+ secondaryLabel: "LinkedIn",
35
+ },
36
+ {
37
+ name: "Jovin Antony Maria",
38
+ url: "https://www.linkedin.com/in/jovin-antony-maria-987262348/",
39
+ linkLabel: "LinkedIn",
40
  },
41
  ];
42
 
 
85
  className="fixed right-3 top-14 sm:absolute sm:right-0 sm:top-full sm:mt-1 rounded-lg border border-edge bg-surface shadow-xl z-40 p-2 flex flex-col gap-0.5 w-[min(20rem,calc(100vw-1.5rem))]"
86
  >
87
  {PEOPLE.map((p) => (
88
+ <div
89
  key={p.name}
90
  role="menuitem"
 
 
 
 
91
  className="px-3 py-2 rounded-md hover:bg-surfaceAlt transition-colors border border-transparent hover:border-edge/60 flex items-center gap-3"
92
  >
93
  <CircleUser className="w-4 h-4 text-mute shrink-0" />
94
  <span className="flex-1 min-w-0 text-sm text-ink font-medium truncate">
95
  {p.name}
96
  </span>
97
+ <div className="flex items-center gap-1.5 shrink-0">
98
+ <a
99
+ href={p.url}
100
+ target="_blank"
101
+ rel="noopener noreferrer"
102
+ onClick={() => setOpen(false)}
103
+ className="flex items-center gap-1 text-[10px] text-mute hover:text-ink font-mono px-1.5 py-0.5 rounded border border-edge/40 hover:border-edge"
104
+ title={`Open ${p.linkLabel} for ${p.name}`}
105
+ >
106
+ {p.linkLabel}
107
+ <ExternalLink className="w-3 h-3" />
108
+ </a>
109
+ {p.secondaryUrl && p.secondaryLabel && (
110
+ <a
111
+ href={p.secondaryUrl}
112
+ target="_blank"
113
+ rel="noopener noreferrer"
114
+ onClick={() => setOpen(false)}
115
+ className="flex items-center gap-1 text-[10px] text-mute hover:text-ink font-mono px-1.5 py-0.5 rounded border border-edge/40 hover:border-edge"
116
+ title={`Open ${p.secondaryLabel} for ${p.name}`}
117
+ >
118
+ {p.secondaryLabel}
119
+ <ExternalLink className="w-3 h-3" />
120
+ </a>
121
+ )}
122
+ </div>
123
+ </div>
124
  ))}
125
  </div>
126
  )}
frontend/src/components/NodePalette.tsx CHANGED
@@ -257,24 +257,48 @@ function PaletteTile({
257
  * used for user-uploaded plugins. */
258
  onDelete?: () => void;
259
  }) {
 
260
  const isPlugin = "isPlugin" in spec && spec.isPlugin;
261
  const Icon = spec.icon;
 
262
  function onDragStart(e: React.DragEvent) {
263
  e.dataTransfer.setData("application/reactflow", spec.kind);
264
  e.dataTransfer.effectAllowed = "move";
265
  }
 
 
 
 
 
 
 
 
 
266
  return (
267
- <div
 
268
  draggable
269
  onDragStart={onDragStart}
270
- className={`group relative shrink-0 cursor-grab active:cursor-grabbing flex flex-col items-center justify-center gap-0.5 w-[108px] h-[76px] rounded-md border transition-colors text-center px-1.5 py-1.5 ${
 
 
 
 
 
 
 
 
 
271
  isPlugin
272
  ? "border-edge bg-surface/60 hover:bg-surfaceAlt"
273
  : "border-edge/60 hover:border-edge hover:bg-surfaceAlt"
274
  }`}
275
  title={spec.description}
 
276
  >
277
- {/* Top-right corner badge: paper link, delete button, or nothing */}
 
 
278
  {spec.paper && !isPlugin && (
279
  <a
280
  href={spec.paper.url}
@@ -283,7 +307,7 @@ function PaletteTile({
283
  draggable={false}
284
  onDragStart={(e) => e.stopPropagation()}
285
  onClick={(e) => e.stopPropagation()}
286
- className="absolute top-1 right-1 w-4 h-4 rounded-full bg-accent/20 border border-accent/70 text-accent hover:bg-accent/40 hover:border-accent hover:text-ink flex items-center justify-center shadow-sm transition-colors z-10"
287
  title={`Paper: ${spec.paper.title} (${spec.paper.venue})`}
288
  aria-label={`Open paper: ${spec.paper.title}`}
289
  >
@@ -291,6 +315,10 @@ function PaletteTile({
291
  </a>
292
  )}
293
  {isPlugin && onDelete && (
 
 
 
 
294
  <button
295
  type="button"
296
  draggable={false}
@@ -299,23 +327,30 @@ function PaletteTile({
299
  e.stopPropagation();
300
  if (window.confirm(`Delete plugin "${spec.label}"?`)) onDelete();
301
  }}
302
- className="absolute top-1 right-1 w-4 h-4 rounded-full border border-edge bg-surface text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
 
 
 
 
 
303
  title={`Delete plugin ${spec.label}`}
304
  aria-label={`Delete plugin ${spec.label}`}
305
  >
306
- <X className="w-2.5 h-2.5" strokeWidth={2.5} />
307
  </button>
308
  )}
309
  {isPlugin ? (
310
  <span
311
  className="w-6 h-6 rounded-md flex items-center justify-center text-[10px] font-bold text-white"
312
  style={{ backgroundColor: (spec as PluginNodeSpec).pluginColor }}
 
313
  >
314
  {(spec as PluginNodeSpec).initials}
315
  </span>
316
  ) : (
317
  <span
318
  className={`w-6 h-6 rounded-md border ${spec.accentRing} bg-surface flex items-center justify-center ${spec.accent}`}
 
319
  >
320
  <Icon className="w-3 h-3" strokeWidth={2} />
321
  </span>
@@ -326,6 +361,6 @@ function PaletteTile({
326
  <span className="text-[9px] text-mute/80 leading-tight max-w-full line-clamp-2">
327
  {spec.tagline}
328
  </span>
329
- </div>
330
  );
331
  }
 
257
  * used for user-uploaded plugins. */
258
  onDelete?: () => void;
259
  }) {
260
+ const addBlocksToCanvas = useApp((s) => s.addBlocksToCanvas);
261
  const isPlugin = "isPlugin" in spec && spec.isPlugin;
262
  const Icon = spec.icon;
263
+
264
  function onDragStart(e: React.DragEvent) {
265
  e.dataTransfer.setData("application/reactflow", spec.kind);
266
  e.dataTransfer.effectAllowed = "move";
267
  }
268
+
269
+ // Tap (mobile) / click (mouse) / Enter+Space (keyboard) all funnel
270
+ // into the same "queue this kind for the canvas" path that the
271
+ // BlockPicker dropdown uses. Drag-and-drop continues to work for
272
+ // mouse users on top of this — they get both interactions.
273
+ function addToCanvas() {
274
+ addBlocksToCanvas([spec.kind]);
275
+ }
276
+
277
  return (
278
+ <button
279
+ type="button"
280
  draggable
281
  onDragStart={onDragStart}
282
+ onClick={addToCanvas}
283
+ // The button gives us Enter/Space → click for free; we override
284
+ // Space below so it doesn't also scroll the strip.
285
+ onKeyDown={(e) => {
286
+ if (e.key === " ") {
287
+ e.preventDefault();
288
+ addToCanvas();
289
+ }
290
+ }}
291
+ className={`group relative shrink-0 cursor-grab active:cursor-grabbing flex flex-col items-center justify-center gap-0.5 w-[108px] h-[76px] rounded-md border transition-colors text-center px-1.5 py-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${
292
  isPlugin
293
  ? "border-edge bg-surface/60 hover:bg-surfaceAlt"
294
  : "border-edge/60 hover:border-edge hover:bg-surfaceAlt"
295
  }`}
296
  title={spec.description}
297
+ aria-label={`Add ${spec.label} block to canvas. ${spec.tagline}`}
298
  >
299
+ {/* Top-right corner badge: paper link, delete button, or nothing.
300
+ These are interactive children; stopPropagation keeps the
301
+ parent button from also firing. */}
302
  {spec.paper && !isPlugin && (
303
  <a
304
  href={spec.paper.url}
 
307
  draggable={false}
308
  onDragStart={(e) => e.stopPropagation()}
309
  onClick={(e) => e.stopPropagation()}
310
+ className="absolute top-1 right-1 w-5 h-5 rounded-full bg-accent/20 border border-accent/70 text-accent hover:bg-accent/40 hover:border-accent hover:text-ink flex items-center justify-center shadow-sm transition-colors z-10"
311
  title={`Paper: ${spec.paper.title} (${spec.paper.venue})`}
312
  aria-label={`Open paper: ${spec.paper.title}`}
313
  >
 
315
  </a>
316
  )}
317
  {isPlugin && onDelete && (
318
+ // Always visible: previously hover-only, which left mobile +
319
+ // keyboard users with no way to find or activate the delete
320
+ // affordance. Slight opacity at rest keeps it from drawing too
321
+ // much focus when the user is browsing the catalogue.
322
  <button
323
  type="button"
324
  draggable={false}
 
327
  e.stopPropagation();
328
  if (window.confirm(`Delete plugin "${spec.label}"?`)) onDelete();
329
  }}
330
+ onKeyDown={(e) => {
331
+ // Don't bubble Enter/Space to the parent button when
332
+ // focused on the delete X.
333
+ if (e.key === "Enter" || e.key === " ") e.stopPropagation();
334
+ }}
335
+ className="absolute top-1 right-1 w-5 h-5 rounded-full border border-edge bg-surface text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity z-10"
336
  title={`Delete plugin ${spec.label}`}
337
  aria-label={`Delete plugin ${spec.label}`}
338
  >
339
+ <X className="w-3 h-3" strokeWidth={2.5} />
340
  </button>
341
  )}
342
  {isPlugin ? (
343
  <span
344
  className="w-6 h-6 rounded-md flex items-center justify-center text-[10px] font-bold text-white"
345
  style={{ backgroundColor: (spec as PluginNodeSpec).pluginColor }}
346
+ aria-hidden
347
  >
348
  {(spec as PluginNodeSpec).initials}
349
  </span>
350
  ) : (
351
  <span
352
  className={`w-6 h-6 rounded-md border ${spec.accentRing} bg-surface flex items-center justify-center ${spec.accent}`}
353
+ aria-hidden
354
  >
355
  <Icon className="w-3 h-3" strokeWidth={2} />
356
  </span>
 
361
  <span className="text-[9px] text-mute/80 leading-tight max-w-full line-clamp-2">
362
  {spec.tagline}
363
  </span>
364
+ </button>
365
  );
366
  }
frontend/src/components/PluginFigures.tsx CHANGED
@@ -347,11 +347,12 @@ function BarBlock({
347
  const barGap = 6;
348
  const minBarW = 14;
349
  const maxBarW = 36;
 
 
 
350
  const width = Math.max(
351
  260,
352
- padLeft +
353
- padRight +
354
- data.length * (Math.max(minBarW, maxBarW * (10 / data.length)) + barGap),
355
  );
356
 
357
  const positiveValues = data.map((d) => Math.max(0, d.value));
@@ -364,12 +365,28 @@ function BarBlock({
364
  ),
365
  );
366
 
 
 
 
 
 
 
 
 
 
 
 
367
  return (
 
368
  <svg
369
  viewBox={`0 0 ${width} ${chartH + padTop + padBottom}`}
370
- className="w-full max-w-full h-auto"
 
 
 
 
371
  role="img"
372
- aria-label="Bar chart"
373
  >
374
  {/* Y-axis label */}
375
  {yLabel && (
@@ -449,6 +466,7 @@ function BarBlock({
449
  </text>
450
  )}
451
  </svg>
 
452
  );
453
  }
454
 
@@ -462,17 +480,34 @@ function truncate(s: string, max: number): string {
462
  }
463
 
464
  // ----- Raw SVG ----------------------------------------------------------
465
- // The backend rejected anything containing <script>, javascript:,
466
- // <foreignObject>, event-handler attrs, etc. We render via
467
- // dangerouslySetInnerHTML — at this point the string is a safer
468
- // subset than typical user-supplied HTML.
 
 
 
469
 
470
  function SvgBlock({ content }: { content: string }) {
 
 
 
 
 
 
 
 
 
 
471
  return (
472
- <div
473
- className="plugin-svg overflow-x-auto"
474
- // eslint-disable-next-line react/no-danger
475
- dangerouslySetInnerHTML={{ __html: content }}
 
 
 
 
476
  />
477
  );
478
  }
 
347
  const barGap = 6;
348
  const minBarW = 14;
349
  const maxBarW = 36;
350
+ // Always give each bar at least minBarW px. When N is large the
351
+ // chart grows past the card width and the outer wrapper scrolls
352
+ // horizontally — that's better than shrinking labels to 5px.
353
  const width = Math.max(
354
  260,
355
+ padLeft + padRight + data.length * (minBarW + barGap),
 
 
356
  );
357
 
358
  const positiveValues = data.map((d) => Math.max(0, d.value));
 
365
  ),
366
  );
367
 
368
+ // Screen-reader friendly summary of the chart. Without this, an
369
+ // assistive-tech user just hears "Bar chart" and can't interrogate
370
+ // the actual data. We keep it brief: count, max, top bar.
371
+ const top = data.reduce(
372
+ (acc, d) => (d.value > acc.value ? d : acc),
373
+ data[0],
374
+ );
375
+ const ariaLabel = `Bar chart of ${data.length} value${
376
+ data.length === 1 ? "" : "s"
377
+ }. Maximum: ${formatBarValue(top.value)} at "${top.label}".`;
378
+
379
  return (
380
+ <div className="overflow-x-auto">
381
  <svg
382
  viewBox={`0 0 ${width} ${chartH + padTop + padBottom}`}
383
+ // No w-full here: when width > container, the parent
384
+ // overflow-x-auto kicks in instead of squashing bars.
385
+ width={width}
386
+ height={chartH + padTop + padBottom}
387
+ style={{ maxWidth: "100%" }}
388
  role="img"
389
+ aria-label={ariaLabel}
390
  >
391
  {/* Y-axis label */}
392
  {yLabel && (
 
466
  </text>
467
  )}
468
  </svg>
469
+ </div>
470
  );
471
  }
472
 
 
480
  }
481
 
482
  // ----- Raw SVG ----------------------------------------------------------
483
+ // The backend's _scrub_figures rejected anything containing <script>,
484
+ // javascript: URLs, <foreignObject>, event-handler attrs, etc. As
485
+ // defense-in-depth we still render inside a sandboxed iframe so a
486
+ // stage-2 bypass (CSS-injection, future SVG attack vectors) can't
487
+ // touch our DOM, cookies, or origin. The iframe has no allow-
488
+ // scripts, no allow-same-origin — even if SVG content somehow runs
489
+ // JS, it can't reach the parent page.
490
 
491
  function SvgBlock({ content }: { content: string }) {
492
+ // Wrap in minimal HTML so the iframe knows it's rendering SVG.
493
+ // body padding 0 + neutral background matches the rest of the card.
494
+ const srcdoc = useMemo(() => {
495
+ const css = `
496
+ html,body{margin:0;padding:0;background:transparent;color:inherit}
497
+ body{overflow:auto;max-width:100%}
498
+ svg{max-width:100%;height:auto;display:block}
499
+ `;
500
+ return `<!doctype html><html><head><meta charset="utf-8"><style>${css}</style></head><body>${content}</body></html>`;
501
+ }, [content]);
502
  return (
503
+ <iframe
504
+ sandbox=""
505
+ title="Plugin SVG figure"
506
+ srcDoc={srcdoc}
507
+ // Iframe content height is unknown until it renders; auto-size
508
+ // via a ResizeObserver would require same-origin, so we settle
509
+ // for a generous default that scrolls if needed.
510
+ className="w-full h-72 border-0"
511
  />
512
  );
513
  }
frontend/src/components/QNode.tsx CHANGED
@@ -66,7 +66,7 @@ export function QNode({ id, data, selected }: NodeProps) {
66
  type="button"
67
  aria-label="Delete this block"
68
  title="Delete this orphaned block"
69
- className="nodrag absolute -top-2 -right-2 w-5 h-5 rounded-full bg-surface border border-edge text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
70
  onClick={(e) => {
71
  e.stopPropagation();
72
  deleteElements({ nodes: [{ id }] });
@@ -117,7 +117,7 @@ export function QNode({ id, data, selected }: NodeProps) {
117
  type="button"
118
  aria-label="Delete this block"
119
  title="Delete this block"
120
- className="nodrag absolute -top-2 -right-2 w-5 h-5 rounded-full bg-surface border border-edge text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
121
  onClick={(e) => {
122
  e.stopPropagation();
123
  deleteElements({ nodes: [{ id }] });
 
66
  type="button"
67
  aria-label="Delete this block"
68
  title="Delete this orphaned block"
69
+ className="nodrag absolute -top-2 -right-2 w-6 h-6 rounded-full bg-surface border border-edge text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity z-10"
70
  onClick={(e) => {
71
  e.stopPropagation();
72
  deleteElements({ nodes: [{ id }] });
 
117
  type="button"
118
  aria-label="Delete this block"
119
  title="Delete this block"
120
+ className="nodrag absolute -top-2 -right-2 w-6 h-6 rounded-full bg-surface border border-edge text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity z-10"
121
  onClick={(e) => {
122
  e.stopPropagation();
123
  deleteElements({ nodes: [{ id }] });
frontend/src/components/UploadPluginModal.tsx CHANGED
@@ -61,7 +61,11 @@ export function UploadPluginModal({
61
  const autoCloseRef = useRef<number | null>(null);
62
 
63
  // Reset transient state every time the modal reopens, and cancel any
64
- // pending auto-close from a previous open cycle.
 
 
 
 
65
  useEffect(() => {
66
  if (open) {
67
  setError(null);
@@ -69,6 +73,19 @@ export function UploadPluginModal({
69
  setBusy(false);
70
  setDragOver(false);
71
  setInstallingExample(null);
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  return () => {
74
  if (autoCloseRef.current !== null) {
 
61
  const autoCloseRef = useRef<number | null>(null);
62
 
63
  // Reset transient state every time the modal reopens, and cancel any
64
+ // pending auto-close from a previous open cycle. Also remember the
65
+ // element that had focus when we opened so we can put focus back on
66
+ // close — without this, keyboard / screen-reader users land at the
67
+ // top of the document after closing.
68
+ const openerRef = useRef<HTMLElement | null>(null);
69
  useEffect(() => {
70
  if (open) {
71
  setError(null);
 
73
  setBusy(false);
74
  setDragOver(false);
75
  setInstallingExample(null);
76
+ openerRef.current = (document.activeElement as HTMLElement) || null;
77
+ } else if (openerRef.current) {
78
+ // Defer one frame so React has flushed; otherwise we focus the
79
+ // element before the modal's portal unmounts and focus jumps.
80
+ const target = openerRef.current;
81
+ requestAnimationFrame(() => {
82
+ try {
83
+ target.focus();
84
+ } catch {
85
+ /* element may be gone */
86
+ }
87
+ });
88
+ openerRef.current = null;
89
  }
90
  return () => {
91
  if (autoCloseRef.current !== null) {
frontend/src/index.css CHANGED
@@ -201,3 +201,24 @@
201
  color: rgb(var(--rf-edge-stroke)) !important;
202
  font-size: 10px !important;
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  color: rgb(var(--rf-edge-stroke)) !important;
202
  font-size: 10px !important;
203
  }
204
+
205
+ /* ----- prefers-reduced-motion ----------------------------------------
206
+ * Honor the OS-level "reduce motion" setting. Without this rule the
207
+ * default React Flow `animated` edges loop a stroke-dash forever, and
208
+ * the various spinners / pulse loaders run regardless of user
209
+ * preference. We keep transitions essentially instant so the UI is
210
+ * still responsive but without continuous motion. */
211
+ @media (prefers-reduced-motion: reduce) {
212
+ *,
213
+ *::before,
214
+ *::after {
215
+ animation-duration: 0.01ms !important;
216
+ animation-iteration-count: 1 !important;
217
+ transition-duration: 0.01ms !important;
218
+ scroll-behavior: auto !important;
219
+ }
220
+ .react-flow__edge-path {
221
+ stroke-dasharray: none !important;
222
+ animation: none !important;
223
+ }
224
+ }