Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: move focus to the delete confirmation instead of the emptied '…' trigger (#3286)

[._.]/ Adam Eivy25a541aaaf75
diff --git a/client/src/components/ui/InlineConfirmRow.jsx b/client/src/components/ui/InlineConfirmRow.jsx
index d72fe98749..8e2dba1153 100644
--- a/client/src/components/ui/InlineConfirmRow.jsx
+++ b/client/src/components/ui/InlineConfirmRow.jsx
@@ -1,3 +1,5 @@
+import { useEffect, useRef } from 'react';
+
// Inline "question + confirm + cancel" row for destructive actions — the
// inline-confirmation pattern PortOS prefers over a two-click-arm button or a
// window.confirm() modal. Shaped for confirm/cancel prompts, which is why these
@@ -38,13 +40,30 @@ export default function InlineConfirmRow({
tone = 'error',
variant = 'box',
className = '',
+ autoFocus = false,
...rest
}) {
const t = TONES[tone] || TONES.error;
const v = VARIANTS[variant] || VARIANTS.box;
+ const rowRef = useRef(null);
+
+ // `autoFocus` moves focus to the row itself (not to the destructive button —
+ // a stray Enter must not delete anything). Callers that reveal this row from
+ // another control (a "…" menu item, a toolbar button) should set it so
+ // keyboard/screen-reader users land on, and hear, the question instead of
+ // being left on a trigger whose menu just vanished. Pair it with an
+ // `aria-label` naming the record so the focus move announces something.
+ useEffect(() => {
+ if (autoFocus) rowRef.current?.focus();
+ }, [autoFocus]);
return (
- <div className={`flex items-center gap-2 ${v.frame} ${t.wrapper} ${className}`.trim()} {...rest}>
+ <div
+ ref={rowRef}
+ tabIndex={autoFocus ? -1 : undefined}
+ className={`flex items-center gap-2 ${v.frame} ${t.wrapper} focus:outline-hidden focus:ring-2 focus:ring-port-accent ${className}`.trim()}
+ {...rest}
+ >
<span className={`${v.question} text-white flex-1`}>{question}</span>
<button
type="button"
diff --git a/client/src/components/ui/InlineConfirmRow.test.jsx b/client/src/components/ui/InlineConfirmRow.test.jsx
index a96d68ccc8..e4b133f088 100644
--- a/client/src/components/ui/InlineConfirmRow.test.jsx
+++ b/client/src/components/ui/InlineConfirmRow.test.jsx
@@ -89,6 +89,21 @@ describe('InlineConfirmRow', () => {
expect(screen.getByRole('button', { name: 'Cancel' }).className).toContain('hover:text-white');
});
+ it('is not focusable by default', () => {
+ render(<InlineConfirmRow question="x" />);
+ const wrapper = screen.getByText('x').closest('div');
+ expect(wrapper.hasAttribute('tabindex')).toBe(false);
+ expect(document.activeElement).toBe(document.body);
+ });
+
+ it('focuses the row (never the destructive button) when autoFocus is set', () => {
+ render(<InlineConfirmRow question="x" autoFocus aria-label="Confirm deletion of Thing" />);
+ const wrapper = screen.getByText('x').closest('div');
+ expect(wrapper.getAttribute('tabindex')).toBe('-1');
+ expect(document.activeElement).toBe(wrapper);
+ expect(document.activeElement).not.toBe(screen.getByRole('button', { name: 'Delete' }));
+ });
+
it('falls back to the box variant for an unknown variant value', () => {
render(<InlineConfirmRow question="x" variant="bogus" />);
const wrapper = screen.getByText('x').closest('div');
diff --git a/client/src/components/ui/OverflowMenu.jsx b/client/src/components/ui/OverflowMenu.jsx
index f062038dc3..0d52dad02a 100644
--- a/client/src/components/ui/OverflowMenu.jsx
+++ b/client/src/components/ui/OverflowMenu.jsx
@@ -89,6 +89,9 @@ export default function OverflowMenu({ label, items = [], className = '' }) {
type="button"
role="menuitem"
disabled={item.disabled}
+ // Close first so focus lands somewhere real; an item that reveals
+ // follow-up UI (an inline confirm) owns moving focus onward from
+ // there — its mount effect runs after this commit and wins.
onClick={() => { close(true); item.onSelect?.(); }}
className={`w-full px-3 py-2 min-h-[40px] text-left text-xs flex items-center gap-2 transition-colors disabled:opacity-50 focus:outline-hidden focus:bg-port-border/70 ${TONES[item.tone] || TONES.default}`}
>
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index 82816f3880..3a61ab9413 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -414,6 +414,7 @@ export default function Apps() {
{confirmingDelete === app.id && (
<InlineConfirmRow
className="mt-3"
+ autoFocus
question={`Delete ${app.name}? This removes it from PortOS and cannot be undone.`}
confirmText="Delete"
cancelText="Cancel"
diff --git a/client/src/pages/Apps.test.jsx b/client/src/pages/Apps.test.jsx
index 26f7c709b9..153d48352a 100644
--- a/client/src/pages/Apps.test.jsx
+++ b/client/src/pages/Apps.test.jsx
@@ -94,6 +94,10 @@ describe('Apps row action hierarchy', () => {
const confirm = screen.getByLabelText('Confirm deletion of Example App');
expect(confirm.textContent).toContain('cannot be undone');
+ // Focus follows the revealed confirmation instead of being stranded on the
+ // "…" trigger whose menu just closed.
+ expect(document.activeElement).toBe(confirm);
+
await user.click(screen.getByRole('button', { name: 'Cancel' }));
expect(api.deleteApp).not.toHaveBeenCalled();
expect(screen.queryByLabelText('Confirm deletion of Example App')).toBeNull();