Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: review feedback — keep action keys native when no step action, scope button shortcuts to the topmost dialog, announce shortcut combos to screen readers

aashud858f80bca06
diff --git a/apps/mes/app/components/AssemblyView.tsx b/apps/mes/app/components/AssemblyView.tsx
index efcc3f2032..8877c423e0 100644
--- a/apps/mes/app/components/AssemblyView.tsx
+++ b/apps/mes/app/components/AssemblyView.tsx
@@ -1234,6 +1234,11 @@ export function AssemblyView({
if (target.closest('[contenteditable="true"], .ProseMirror')) return;
}
+ // No primary action (step done, gated, or submitting) → leave the
+ // action keys native, so a keyboard user who focused Skip can still
+ // activate it with Space/Enter.
+ if (isAction && !primaryStepActionRef.current) return;
+
event.preventDefault();
event.stopPropagation();
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index 465222cd88..509ae79ac2 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -8,7 +8,7 @@ import { useShortcutKeys } from "./hooks/useShortcutKeys";
import { ShortcutKey } from "./ShortcutKey";
import { Spinner } from "./Spinner";
import { cn } from "./utils/cn";
-import { hasOpenDialog, isInsideOpenDialog } from "./utils/dialog";
+import { hasOpenDialog, isInsideTopmostDialog } from "./utils/dialog";
import { mergeRefs } from "./utils/react";
export const buttonVariants = cva(
@@ -166,10 +166,11 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
const badgeShortcut =
!hideShortcutKey && !isIcon && !isLoading ? primaryShortcut : undefined;
- // While any dialog is open, only buttons inside one respond to their
- // shortcut — a background ⌘S must not fire under a confirmation modal.
+ // While any dialog is open, only buttons inside the TOPMOST one respond
+ // to their shortcut — a background (or outer-dialog) ⌘S must not fire
+ // under a confirmation modal stacked on top.
const dialogGuard = useCallback(
- () => !hasOpenDialog() || isInsideOpenDialog(innerRef.current),
+ () => !hasOpenDialog() || isInsideTopmostDialog(innerRef.current),
[]
);
diff --git a/packages/react/src/ShortcutKey.tsx b/packages/react/src/ShortcutKey.tsx
index 3aff39577a..eec03f5f79 100644
--- a/packages/react/src/ShortcutKey.tsx
+++ b/packages/react/src/ShortcutKey.tsx
@@ -59,13 +59,21 @@ export const ShortcutKey = ({
if (!relevantShortcut) return null;
const modifiers = relevantShortcut.modifiers ?? [];
const character = keyString(String(relevantShortcut.key), isMac, variant);
+ // Glyphs/SVGs carry no accessible name, so announce the combo as text and
+ // hide the visual keycap content from the accessibility tree.
+ const readableShortcut = [...modifiers, String(relevantShortcut.key)].join(
+ "+"
+ );
return (
<span className={cn(shortcutKeyVariants[variant], className)}>
- {modifiers.map((k) => (
- <Fragment key={k}>{modifierNode(k, isMac, variant)}</Fragment>
- ))}
- {character}
+ <span className="sr-only">{readableShortcut}</span>
+ <span aria-hidden="true" className="contents">
+ {modifiers.map((k) => (
+ <Fragment key={k}>{modifierNode(k, isMac, variant)}</Fragment>
+ ))}
+ {character}
+ </span>
</span>
);
};
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index 0509effdd1..74f9c7c8be 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -346,7 +346,7 @@ import {
import { TruncatedTooltipText } from "./TruncatedTooltipText";
import { TVColorBars } from "./TVColorBars";
import { cn } from "./utils/cn";
-import { hasOpenDialog, isInsideOpenDialog } from "./utils/dialog";
+import { hasOpenDialog, isInsideTopmostDialog } from "./utils/dialog";
import { copyToClipboard } from "./utils/dom";
import { getValidChildren, reactNodeToString } from "./utils/react";
import { VStack } from "./VStack";
@@ -575,7 +575,7 @@ export {
KeyboardKeys,
ShortcutKey,
hasOpenDialog,
- isInsideOpenDialog,
+ isInsideTopmostDialog,
Sidebar,
SidebarContent,
SidebarFooter,
diff --git a/packages/react/src/utils/dialog.ts b/packages/react/src/utils/dialog.ts
index 0af4021da8..c8f19c6d2e 100644
--- a/packages/react/src/utils/dialog.ts
+++ b/packages/react/src/utils/dialog.ts
@@ -7,9 +7,19 @@ export function hasOpenDialog(): boolean {
return document.querySelector(OPEN_DIALOG_SELECTOR) !== null;
}
-export function isInsideOpenDialog(element: Element | null): boolean {
+// Portals mount in stacking order, so the last open dialog in the DOM is the
+// one on top.
+export function topmostOpenDialog(): Element | null {
+ const dialogs = document.querySelectorAll(OPEN_DIALOG_SELECTOR);
+ return dialogs[dialogs.length - 1] ?? null;
+}
+
+/**
+ * True when the element sits inside the dialog currently on top — a button in
+ * an outer dialog covered by a nested one does NOT qualify, so its shortcut
+ * stays quiet.
+ */
+export function isInsideTopmostDialog(element: Element | null): boolean {
if (!element) return false;
- return Array.from(document.querySelectorAll(OPEN_DIALOG_SELECTOR)).some(
- (dialog) => dialog.contains(element)
- );
+ return topmostOpenDialog()?.contains(element) ?? false;
}