fix(ui): prevent previous titlebar menu from flashing on switch
Scope `.menu` and `.tooltip` enter animations to their open data-state selectors and explicitly set `animation: none` on `[data-state="closed"]` so Radix Presence unmounts closing menus immediately instead of replaying `menu-in` for 160ms when `data-menubar-switch` is removed during a sibling switch. Also keep `data-menubar-switch` active across the switch frame, narrow `onPointerDownOutside` to sibling menu buttons so clicks in the gap still dismiss, fix `prefers-reduced-motion` close animations (adding `fade-out` for closing toasts), and add a static guard in `test-i18n.mjs`.
This commit is contained in:
1 parent
a1b8e96c3d
commit
6fbcd6422e
3 files changed
+56
-8
No files matched your search
@@ -137,6 +137,45 @@ test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and t
|
||||
}
|
||||
})
|
||||
|
||||
test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never replay on close', () => {
|
||||
const css = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8')
|
||||
const titleMenus = fs.readFileSync(path.join(srcDir, 'components', 'TitleMenus.tsx'), 'utf8')
|
||||
|
||||
// Unconditional `.menu { ... animation: ... }` causes Radix Presence to detect an
|
||||
// animationName change (`none` -> `menu-in`) when `data-menubar-switch` is removed on close,
|
||||
// suspending unmount and flashing the previous menu for 160ms.
|
||||
assert.doesNotMatch(
|
||||
css,
|
||||
/\.menu\s*\{[^}]*animation\s*:/,
|
||||
'Enter animation on .menu must be scoped to .menu[data-state="open"]',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.menu\[data-state="open"\]\s*\{[^}]*animation\s*:/,
|
||||
'.menu[data-state="open"] must define the menu enter animation',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.menu\[data-state="closed"\]\s*\{[^}]*animation\s*:\s*none/,
|
||||
'.menu[data-state="closed"] must explicitly disable animation so Radix Presence unmounts immediately',
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
css,
|
||||
/\.tooltip\s*\{[^}]*animation\s*:/,
|
||||
'Enter animation on .tooltip must be scoped to .tooltip[data-state="delayed-open"]',
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.tooltip\[data-state="closed"\]\s*\{[^}]*animation\s*:\s*none/,
|
||||
'.tooltip[data-state="closed"] must explicitly disable animation',
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
titleMenus,
|
||||
/data-menubar-switch=\{\s*menuState\.id\s*===\s*id\s*&&\s*menuState\.switched/,
|
||||
'TitleMenus must not strip data-menubar-switch from the outgoing sibling menu on switch',
|
||||
)
|
||||
})
|
||||
|
||||
test('Runtime i18n v2: ICU formatting, ghost-locale isolation (H-3), parseAppError (HIGH-2), RTL (L-2), and en-XA', async () => {
|
||||
const mod = await loadBundledTS(`
|
||||
import './i18n/domains/wizard.gen'
|
||||
|
||||
@@ -146,7 +146,7 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
<Menu.Portal>
|
||||
<Menu.Content
|
||||
className={`menu titlebar-menu-content${indented ? ' menu-indented' : ''}`}
|
||||
data-menubar-switch={menuState.id === id && menuState.switched ? 'true' : undefined}
|
||||
data-menubar-switch={menuState.switched ? 'true' : undefined}
|
||||
align="start"
|
||||
sideOffset={4}
|
||||
collisionPadding={8}
|
||||
@@ -159,8 +159,9 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
pointerClosedRef.current = false
|
||||
}}
|
||||
onPointerDownOutside={(e) => {
|
||||
const target = e.target as Node | null
|
||||
if (target && navRef.current?.contains(target)) {
|
||||
const target = e.target instanceof Element ? e.target : (e.target as Node | null)?.parentElement ?? null
|
||||
const trigger = target?.closest('button.titlebar-menu') ?? null
|
||||
if (trigger && navRef.current?.contains(trigger)) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1331,6 +1331,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
/* ── Motion (emil-design-eng & apple-design) ───────────── */
|
||||
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
||||
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
|
||||
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -49%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
|
||||
@keyframes menu-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
|
||||
@keyframes tip-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
|
||||
@@ -1342,10 +1343,13 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.page { animation: rise-in var(--dur) var(--ease-out) both; }
|
||||
.overlay { animation: fade-in var(--dur) var(--ease-out) both; }
|
||||
.dialog { animation: pop-in var(--dur-modal) var(--ease-out) both; }
|
||||
.menu { transform-origin: var(--radix-dropdown-menu-content-transform-origin, top); animation: menu-in 160ms var(--ease-out) both; }
|
||||
.menu[data-menubar-switch="true"] { animation: none; }
|
||||
.tooltip { animation: tip-in 125ms var(--ease-out) both; }
|
||||
.tooltip[data-state="instant-open"] { animation-duration: 0ms; }
|
||||
.menu { transform-origin: var(--radix-dropdown-menu-content-transform-origin, top); }
|
||||
.menu[data-state="open"] { animation: menu-in 160ms var(--ease-out) both; }
|
||||
.menu[data-state="open"][data-menubar-switch="true"],
|
||||
.menu[data-state="closed"] { animation: none; }
|
||||
.tooltip[data-state="delayed-open"] { animation: tip-in 125ms var(--ease-out) both; }
|
||||
.tooltip[data-state="instant-open"],
|
||||
.tooltip[data-state="closed"] { animation: none; }
|
||||
.pane-anim { display: flex; flex-direction: column; gap: 20px; animation: rise-in var(--dur) var(--ease-out) both; }
|
||||
.step-anim { display: flex; flex-direction: column; gap: var(--sp-4); animation: rise-in var(--dur) var(--ease-out) both; }
|
||||
|
||||
@@ -1496,10 +1500,14 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.status-busy, .vm-screen-live, .skeleton-bar { animation: none; }
|
||||
.vm-display-unit, .vm-display-unit.is-actionable:hover, .vm-display-unit.is-actionable:active { transform: none; }
|
||||
.vm-screen-img, .vm-spec-meter .meter-fill { transition: none; }
|
||||
.page, .dialog, .menu, .tooltip, .pane-anim, .step-anim, .toast[data-state="open"], .toast[data-state="closed"] {
|
||||
.page, .dialog, .menu[data-state="open"]:not([data-menubar-switch="true"]), .tooltip[data-state="delayed-open"], .pane-anim, .step-anim, .toast[data-state="open"] {
|
||||
animation-name: fade-in;
|
||||
animation-duration: 140ms;
|
||||
}
|
||||
.toast[data-state="closed"] {
|
||||
animation-name: fade-out;
|
||||
animation-duration: 140ms;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── v0.2.6 Enhancements: Screenshot, Note, Dropzone, Snapshots, Log Filter, Welcome ── */
|
||||
|
||||
Reference in new issue
Block a user