Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): keep confirm dialogs movable (#2872)

Lizi069579d6657c
diff --git a/apps/desktop/src/renderer/components/layout/windowDrag.tsx b/apps/desktop/src/renderer/components/layout/windowDrag.tsx
index 0be56e0377..b0ab1a836b 100644
--- a/apps/desktop/src/renderer/components/layout/windowDrag.tsx
+++ b/apps/desktop/src/renderer/components/layout/windowDrag.tsx
@@ -11,9 +11,11 @@
* <InvisibleWindowDragStrip />。
*
* ⚠️ Electron 拖拽区域是纯几何计算:drag 矩形减 no-drag 矩形,与 z-index /
- * DOM 层级无关。交互元素漏标 no-drag 会变成"点了就拖窗口";反之 drag 条
- * 叠在交互元素上同样会吞掉点击 —— InvisibleWindowDragStrip 只能用在顶部
- * 确实无交互元素的页面。
+ * paint 顺序无关;但 no-drag 挖洞只在 drag 元素自己的**后代**上可靠生效,
+ * 浮层/兄弟节点上的 no-drag 不被计入(实机结论,见 ContentHeader.tsx:155-157
+ * / FileTabsBar.tsx:421-425)。交互元素漏标 no-drag 会变成"点了就拖窗口";
+ * 反之 drag 条叠在交互元素上同样会吞掉点击 —— InvisibleWindowDragStrip
+ * 只能用在顶部确实无交互元素的页面。
*
* Windows 上通用 header 不隐藏(窗口控制按钮常驻),这些拖拽区是纯增益。
*/
diff --git a/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx b/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx
index 06113dae25..ce8cb7b2f8 100644
--- a/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx
+++ b/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx
@@ -2,11 +2,15 @@
/**
* confirmDialogScroll.test.tsx — 共享 ConfirmDialog 的「长内容不溢出屏幕」契约。
*
- * 这里锁三件事(都是授权确认框出过的真实问题):
+ * 这里锁四件事(都是授权确认框出过的真实问题):
* 1. 弹窗自己限高(max-h-[85vh])、标题与按钮固定,长内容在内部滚动;
* 2. 滚动主体只有一个 —— caller 不必也不该再套一层限高;
* 3. 弹窗一出现就闪一下滚动条:thumb 默认透明,不提示就等于让用户在
- * 「还有权限没看到」的情况下点同意。
+ * 「还有权限没看到」的情况下点同意;
+ * 4. 确认框打开时,遮罩(Overlay 即全屏 drag 区)仍可拖动无边框窗口,弹窗内容
+ * 作为遮罩的 DOM 后代保持 no-drag(挖洞只在 drag 元素的后代上可靠生效),
+ * 且居中走布局而非 transform —— app-region 命中区不跟随 transform,挖洞
+ * 必须与弹窗视觉位置重合;关闭后遮罩随 Radix Presence 卸载,不留常驻拖拽区。
*/
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -65,6 +69,68 @@ describe('ConfirmDialog 长内容布局', () => {
expect((confirmBtn.parentElement as HTMLElement).className).toContain('shrink-0');
});
+ it('确认框遮罩保留窗口拖动,弹窗以 drag 遮罩的后代挖洞,且居中不走 transform', () => {
+ render(
+ <ConfirmDialog
+ open
+ onOpenChange={() => {}}
+ title="安装插件"
+ content={longContent}
+ confirmText="安装插件"
+ />,
+ );
+
+ const dialog = screen.getByRole('alertdialog');
+ // 全屏 drag 遮罩(Overlay)是弹窗的 DOM 父级:no-drag 挖洞只在 drag 元素
+ // 自己的后代上可靠生效(实机结论,ContentHeader.tsx:155-157),弹窗必须
+ // 嵌在遮罩里,而不能是与 drag 遮罩平级的 Portal 兄弟。
+ const dragRegion = dialog.parentElement as HTMLElement;
+ expect(dragRegion).not.toBeNull();
+ expect(
+ (dragRegion.style as CSSStyleDeclaration & { WebkitAppRegion: string }).WebkitAppRegion,
+ ).toBe('drag');
+ expect(
+ (dialog.style as CSSStyleDeclaration & { WebkitAppRegion: string }).WebkitAppRegion,
+ ).toBe('no-drag');
+ // 遮罩自身带 Radix 管理的 data-state:Portal 的 Presence 依赖它配合
+ // 退场动画延迟卸载,弹窗退场(150ms)不会瞬间消失。
+ expect(dragRegion.getAttribute('data-state')).toBe('open');
+ // 居中必须走布局(inset-0 + m-auto)而非 transform:Electron 的 app-region
+ // 命中区按布局矩形计算、不跟随 transform,用 -translate-* 定位会让
+ // no-drag 挖洞与弹窗视觉位置错位(点击弹窗内容会变成拖窗)。
+ expect(dialog.className).not.toMatch(/-translate-/);
+ expect(dialog.className).toContain('inset-0');
+ expect(dialog.className).toContain('m-auto');
+ expect(dialog.className).toContain('h-fit');
+ // 动画必须走无 translate 的 layout keyframes:共享 confirm-content-in/out
+ // 的每一帧都烘 translate(-50%, -50%),布局居中弹窗用它会在入退场期间
+ // 被甩出 no-drag 挖洞(tailwind.config.ts 注释同步钉住这条分工)。
+ expect(dialog.className).toContain('animate-confirm-content-layout-in');
+ expect(dialog.className).toContain('animate-confirm-content-layout-out');
+ expect(dialog.className).not.toContain('animate-confirm-content-in');
+ expect(dialog.className).not.toContain('animate-confirm-content-out');
+ });
+
+ it('关闭后全屏 drag 遮罩随 Presence 卸载,不留常驻拖拽区', () => {
+ const props = {
+ onOpenChange: () => {},
+ title: '安装插件',
+ content: longContent,
+ confirmText: '安装插件',
+ };
+ const { rerender } = render(<ConfirmDialog open {...props} />);
+ const dragRegion = screen.getByRole('alertdialog').parentElement as HTMLElement;
+
+ rerender(<ConfirmDialog open={false} {...props} />);
+
+ // Radix 对 Portal 直接子元素套 Presence:遮罩 data-state 翻转 + 退场动画
+ // 结束后卸载(jsdom 无 CSS 动画,走无动画分支立即卸载)。任何路径下
+ // 全屏 drag 遮罩都不能残留在 DOM 里 —— 否则会成为常驻的全屏窗口拖拽区,
+ // 吞掉整个应用的点击。
+ expect(document.body.contains(dragRegion)).toBe(false);
+ expect(screen.queryByRole('alertdialog')).toBeNull();
+ });
+
it('打开时闪一下滚动条,内容里的点击(如展开折叠区)后再闪一次', async () => {
render(
<ConfirmDialog
@@ -87,9 +153,7 @@ describe('ConfirmDialog 长内容布局', () => {
});
it('没有正文也没有富内容时不渲染滚动区(短弹窗排版不变)', () => {
- render(
- <ConfirmDialog open onOpenChange={() => {}} title="确定退出?" confirmText="退出" />,
- );
+ render(<ConfirmDialog open onOpenChange={() => {}} title="确定退出?" confirmText="退出" />);
const dialog = screen.getByRole('alertdialog');
expect(dialog.querySelectorAll('.overflow-y-auto').length).toBe(0);
expect(flashScrollbar).not.toHaveBeenCalled();
diff --git a/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx b/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
index f8189b7785..60a572cf14 100644
--- a/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
+++ b/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { flashScrollbar } from '@/lib/scrollbarAutoHide';
import { cn } from '@/lib/utils';
+import { WINDOW_DRAG_STYLE, WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';
import { Spinner } from '@/components/ui/spinner';
export interface ConfirmDialogProps {
@@ -136,6 +137,18 @@ export function ConfirmDialog({
return (
<AlertDialog.Root open={open} onOpenChange={onOpenChange}>
<AlertDialog.Portal>
+ {/* 遮罩即全屏 drag 区:no-drag 挖洞只在 drag 元素自己的**后代**上
+ 可靠生效,浮层/兄弟节点上的 no-drag 不被计入(实机结论,见
+ ContentHeader.tsx:155-157 / FileTabsBar.tsx:421-425)。因此弹窗
+ Content 必须是遮罩的 DOM 后代,不能是与 drag 遮罩平级的 Portal
+ 兄弟。遮罩空白区域保留窗口拖动(避免无边框窗口在单屏边缘打开
+ 确认框后无法移回),弹窗内按钮、复选框和滚动区照常交互。
+
+ 生命周期交给 Radix:遮罩自身带 data-state 与 150ms 退场动画,
+ Portal 的 Presence 会等动画播完再卸载;若换成无 Presence 语义的
+ 普通包装层,Portal 会在 open 变 false 时立即卸载它,退场动画被
+ 切断、弹窗瞬间消失(react-dialog 对 Portal 的每个直接子元素都
+ 套一层 Presence)。 */}
<AlertDialog.Overlay
className={cn(
'fixed inset-0 z-[10000]',
@@ -143,154 +156,142 @@ export function ConfirmDialog({
'data-[state=open]:animate-confirm-overlay-in',
'data-[state=closed]:animate-confirm-overlay-out',
)}
- style={{ WebkitAppRegion: 'no-drag', zIndex } as React.CSSProperties}
- />
- <AlertDialog.Content
- className={cn(
- 'fixed left-1/2 top-1/2 z-[10000] -translate-x-1/2 -translate-y-1/2',
- 'flex max-h-[85vh] flex-col',
- 'w-full select-none rounded-xl p-4',
- 'bg-[var(--confirm-bg)] shadow-[var(--confirm-shadow)]',
- 'data-[state=open]:animate-confirm-content-in',
- 'data-[state=closed]:animate-confirm-content-out',
- )}
- style={{ WebkitAppRegion: 'no-drag', maxWidth: maxWidth ?? 400, zIndex } as React.CSSProperties}
- {...(describeContent && content
- ? // 指向滚动区(含 description 与 content):开场朗读覆盖清单全文。
- { 'aria-describedby': bodyId }
- : !description
- ? { 'aria-describedby': undefined }
- : {})}
- onEscapeKeyDown={(e) => {
- if (loading) e.preventDefault();
- }}
- onOpenAutoFocus={
- autoFocusConfirm
- ? (e) => {
- // Radix 默认聚焦第一个可聚焦元素 / Cancel —— 这里覆盖,
- // 把焦点交给主按钮,避免"取消"天然带 focus ring。
- e.preventDefault();
- confirmBtnRef.current?.focus();
- }
- : undefined
- }
+ style={{ ...WINDOW_DRAG_STYLE, zIndex }}
>
- <AlertDialog.Title
- className={cn('shrink-0 text-lg font-medium text-[var(--confirm-title)]', textClassName)}
+ <AlertDialog.Content
+ className={cn(
+ // 居中不用 transform(-translate-x/y-1/2):Electron 的 -webkit-app-region
+ // 命中区域按布局矩形计算、不跟随 transform(ChromeActions.tsx 的既有结论),
+ // transform 定位会让 no-drag 挖洞与弹窗视觉位置错位,点弹窗内容会变成拖窗。
+ // inset-0 + m-auto + h-fit:布局矩形即视觉矩形,挖洞与弹窗严格重合。
+ 'fixed inset-0 z-[10000] m-auto h-fit',
+ 'flex max-h-[85vh] flex-col',
+ 'w-full select-none rounded-xl p-4',
+ 'bg-[var(--confirm-bg)] shadow-[var(--confirm-shadow)]',
+ // 布局居中弹窗用无 translate 的 layout keyframes;共享
+ // confirm-content-in/out 的每一帧都烘 translate(-50%, -50%),
+ // 动画期间会把弹窗整体甩出 no-drag 挖洞。
+ 'data-[state=open]:animate-confirm-content-layout-in',
+ 'data-[state=closed]:animate-confirm-content-layout-out',
+ )}
+ style={{ ...WINDOW_NO_DRAG_STYLE, maxWidth: maxWidth ?? 400, zIndex }}
+ {...(describeContent && content
+ ? // 指向滚动区(含 description 与 content):开场朗读覆盖清单全文。
+ { 'aria-describedby': bodyId }
+ : !description
+ ? { 'aria-describedby': undefined }
+ : {})}
+ onEscapeKeyDown={(e) => {
+ if (loading) e.preventDefault();
+ }}
+ onOpenAutoFocus={
+ autoFocusConfirm
+ ? (e) => {
+ // Radix 默认聚焦第一个可聚焦元素 / Cancel —— 这里覆盖,
+ // 把焦点交给主按钮,避免"取消"天然带 focus ring。
+ e.preventDefault();
+ confirmBtnRef.current?.focus();
+ }
+ : undefined
+ }
>
- {title}
- </AlertDialog.Title>
- {(description || content) && (
- // 富内容 / 长正文可能超过视口高度:包一层限高滚动区,让标题与底部按钮
- // 固定、中间内容纵向滚动,避免整个弹窗被撑出屏幕后无法滚动到被裁掉的内容
- // (典型:插件更新确认框的权限变更清单)。
- <div
- ref={scrollRef}
- id={describeContent && content ? bodyId : undefined}
- // 内容里的折叠区(如权限清单的工具组)展开后高度会变,capture 阶段
- // 收一次点击、下一帧重新判定是否可滚,让滚动条跟着新高度再闪一下。
- onClickCapture={revealScrollbar}
+ <AlertDialog.Title
className={cn(
- 'min-h-0 flex-1 overflow-y-auto overscroll-contain',
- // 保持旧间距:有 description 时紧跟标题 mt-2;仅富内容(无正文)
- // 时沿用原 content 的 mt-3,避免 content-only 弹窗间距变化。
- description ? 'mt-2' : 'mt-3',
+ 'shrink-0 text-lg font-medium text-[var(--confirm-title)]',
+ textClassName,
)}
>
- {description && (
- <AlertDialog.Description
- className={cn('text-base text-[var(--confirm-desc)]', textClassName)}
- >
- {description}
- </AlertDialog.Description>
- )}
- {content && <div className={cn(description && 'mt-3')}>{content}</div>}
- </div>
- )}
- {dontShowAgainLabel && (
- <label
- className={cn(
- 'mt-4 flex shrink-0 cursor-pointer select-none items-center gap-2 text-13',
- 'text-[var(--confirm-desc)]',
- )}
- >
- <input
- type="checkbox"
- checked={dontShowAgain}
- onChange={(e) => setDontShowAgain(e.target.checked)}
- className="size-3.5 cursor-pointer accent-[var(--confirm-btn-primary-bg)]"
- />
- {dontShowAgainLabel}
- </label>
- )}
- <div className="mt-6 flex shrink-0 justify-end gap-2.5">
- <AlertDialog.Action asChild>
- <button
- ref={confirmBtnRef}
- disabled={loading || confirmDisabled}
- aria-busy={loading || undefined}
- aria-label={resolvedConfirmText}
- onClick={() => onConfirm?.({ dontShowAgain })}
+ {title}
+ </AlertDialog.Title>
+ {(description || content) && (
+ // 富内容 / 长正文可能超过视口高度:包一层限高滚动区,让标题与底部按钮
+ // 固定、中间内容纵向滚动,避免整个弹窗被撑出屏幕后无法滚动到被裁掉的内容
+ // (典型:插件更新确认框的权限变更清单)。
+ <div
+ ref={scrollRef}
+ id={describeContent && content ? bodyId : undefined}
+ // 内容里的折叠区(如权限清单的工具组)展开后高度会变,capture 阶段
+ // 收一次点击、下一帧重新判定是否可滚,让滚动条跟着新高度再闪一下。
+ onClickCapture={revealScrollbar}
className={cn(
- 'inline-flex min-w-[96px] items-center justify-center rounded-full px-6 py-2.5 text-13 font-medium',
- 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
- 'active:scale-[0.98]',
- confirmVariant === 'destructive'
- ? 'bg-[hsl(var(--destructive))] text-[var(--accent-pure-cta-fg)] hover:opacity-90 focus-visible:ring-[var(--focus-ring)]'
- : 'bg-[var(--confirm-btn-primary-bg)] text-[var(--confirm-btn-primary-text)] hover:bg-[var(--confirm-btn-primary-hover)] focus-visible:ring-[var(--confirm-btn-primary-bg)]',
- loading &&
- confirmVariant === 'default' &&
- 'cursor-default opacity-80 active:scale-100 hover:bg-[var(--confirm-btn-primary-bg)]',
- loading &&
- confirmVariant === 'destructive' &&
- 'cursor-default opacity-80 active:scale-100 hover:opacity-80',
- confirmDisabled && 'cursor-not-allowed opacity-50 active:scale-100',
+ 'min-h-0 flex-1 overflow-y-auto overscroll-contain',
+ // 保持旧间距:有 description 时紧跟标题 mt-2;仅富内容(无正文)
+ // 时沿用原 content 的 mt-3,避免 content-only 弹窗间距变化。
+ description ? 'mt-2' : 'mt-3',
)}
>
- {loading ? (
- <>
- <Spinner size={14} />
- <span className="sr-only">{resolvedConfirmText}</span>
- </>
- ) : (
- <>
- {confirmIcon && (
- <span className="mr-1.5 inline-flex shrink-0" aria-hidden="true">
- {confirmIcon}
- </span>
- )}
- {resolvedConfirmText}
- </>
+ {description && (
+ <AlertDialog.Description
+ className={cn('text-base text-[var(--confirm-desc)]', textClassName)}
+ >
+ {description}
+ </AlertDialog.Description>
)}
- </button>
- </AlertDialog.Action>
- {tertiaryText && (
- // tertiary 走 secondary 同款轮廓样式 —— 视觉上 "中性可选";
- // 不用 AlertDialog.Action / Cancel,自己 onClick 触发,Radix 不会
- // 自动关 dialog,因此外层得在 onTertiary 里手动 onOpenChange(false)。
- <button
- type="button"
- disabled={loading}
- onClick={() => onTertiary?.()}
+ {content && <div className={cn(description && 'mt-3')}>{content}</div>}
+ </div>
+ )}
+ {dontShowAgainLabel && (
+ <label
className={cn(
- 'inline-flex min-w-[96px] items-center justify-center rounded-full px-6 py-2.5 text-13 font-medium',
- 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
- 'active:scale-[0.98]',
- 'border bg-transparent',
- 'border-[var(--confirm-btn-secondary-border)] text-[var(--confirm-btn-secondary-text)]',
- 'hover:bg-[var(--confirm-btn-secondary-hover)]',
- 'focus-visible:ring-[var(--confirm-btn-secondary-border)]',
- loading && 'cursor-default opacity-50 active:scale-100 hover:bg-transparent',
+ 'mt-4 flex shrink-0 cursor-pointer select-none items-center gap-2 text-13',
+ 'text-[var(--confirm-desc)]',
)}
>
- {tertiaryText}
- </button>
+ <input
+ type="checkbox"
+ checked={dontShowAgain}
+ onChange={(e) => setDontShowAgain(e.target.checked)}
+ className="size-3.5 cursor-pointer accent-[var(--confirm-btn-primary-bg)]"
+ />
+ {dontShowAgainLabel}
+ </label>
)}
- {showCancel && (
- <AlertDialog.Cancel asChild>
+ <div className="mt-6 flex shrink-0 justify-end gap-2.5">
+ <AlertDialog.Action asChild>
<button
+ ref={confirmBtnRef}
+ disabled={loading || confirmDisabled}
+ aria-busy={loading || undefined}
+ aria-label={resolvedConfirmText}
+ onClick={() => onConfirm?.({ dontShowAgain })}
+ className={cn(
+ 'inline-flex min-w-[96px] items-center justify-center rounded-full px-6 py-2.5 text-13 font-medium',
+ 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
+ 'active:scale-[0.98]',
+ confirmVariant === 'destructive'
+ ? 'bg-[hsl(var(--destructive))] text-[var(--accent-pure-cta-fg)] hover:opacity-90 focus-visible:ring-[var(--focus-ring)]'
+ : 'bg-[var(--confirm-btn-primary-bg)] text-[var(--confirm-btn-primary-text)] hover:bg-[var(--confirm-btn-primary-hover)] focus-visible:ring-[var(--confirm-btn-primary-bg)]',
+ loading &&
+ confirmVariant === 'default' &&
+ 'cursor-default opacity-80 active:scale-100 hover:bg-[var(--confirm-btn-primary-bg)]',
+ loading &&
+ confirmVariant === 'destructive' &&
+ 'cursor-default opacity-80 active:scale-100 hover:opacity-80',
+ confirmDisabled && 'cursor-not-allowed opacity-50 active:scale-100',
+ )}
+ >
+ {loading ? (
+ <Spinner size={14} />
+ ) : (
+ <>
+ {confirmIcon && (
+ <span className="mr-1.5 inline-flex shrink-0" aria-hidden="true">
+ {confirmIcon}
+ </span>
+ )}
+ {resolvedConfirmText}
+ </>
+ )}
+ </button>
+ </AlertDialog.Action>
+ {tertiaryText && (
+ // tertiary 走 secondary 同款轮廓样式 —— 视觉上 "中性可选";
+ // 不用 AlertDialog.Action / Cancel,自己 onClick 触发,Radix 不会
+ // 自动关 dialog,因此外层得在 onTertiary 里手动 onOpenChange(false)。
+ <button
+ type="button"
disabled={loading}
- onClick={() => onCancel?.()}
+ onClick={() => onTertiary?.()}
className={cn(
'inline-flex min-w-[96px] items-center justify-center rounded-full px-6 py-2.5 text-13 font-medium',
'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
@@ -302,12 +303,32 @@ export function ConfirmDialog({
loading && 'cursor-default opacity-50 active:scale-100 hover:bg-transparent',
)}
>
- {resolvedCancelText}
+ {tertiaryText}
</button>
- </AlertDialog.Cancel>
- )}
- </div>
- </AlertDialog.Content>
+ )}
+ {showCancel && (
+ <AlertDialog.Cancel asChild>
+ <button
+ disabled={loading}
+ onClick={() => onCancel?.()}
+ className={cn(
+ 'inline-flex min-w-[96px] items-center justify-center rounded-full px-6 py-2.5 text-13 font-medium',
+ 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
+ 'active:scale-[0.98]',
+ 'border bg-transparent',
+ 'border-[var(--confirm-btn-secondary-border)] text-[var(--confirm-btn-secondary-text)]',
+ 'hover:bg-[var(--confirm-btn-secondary-hover)]',
+ 'focus-visible:ring-[var(--confirm-btn-secondary-border)]',
+ loading && 'cursor-default opacity-50 active:scale-100 hover:bg-transparent',
+ )}
+ >
+ {resolvedCancelText}
+ </button>
+ </AlertDialog.Cancel>
+ )}
+ </div>
+ </AlertDialog.Content>
+ </AlertDialog.Overlay>
</AlertDialog.Portal>
</AlertDialog.Root>
);
diff --git a/apps/desktop/src/renderer/styles/globals.css b/apps/desktop/src/renderer/styles/globals.css
index 5b93af02e9..824beac3d1 100644
--- a/apps/desktop/src/renderer/styles/globals.css
+++ b/apps/desktop/src/renderer/styles/globals.css
@@ -194,7 +194,9 @@
.animate-confirm-overlay-in,
.animate-confirm-overlay-out,
.animate-confirm-content-in,
- .animate-confirm-content-out {
+ .animate-confirm-content-out,
+ .animate-confirm-content-layout-in,
+ .animate-confirm-content-layout-out {
animation-duration: 0ms !important;
}
diff --git a/apps/desktop/tailwind.config.ts b/apps/desktop/tailwind.config.ts
index 9a7997213c..c903107976 100644
--- a/apps/desktop/tailwind.config.ts
+++ b/apps/desktop/tailwind.config.ts
@@ -113,6 +113,11 @@ const config: Config = {
from: { opacity: '1' },
to: { opacity: '0' },
},
+ // 共享 confirm-content-in/out:存量弹窗仍是 left-1/2 top-1/2 +
+ // -translate-x/y-1/2 的 transform 居中,动画期间 keyframes 的 transform
+ // 会整体覆盖 Tailwind 的 translate —— 不把 translate(-50%, -50%) 烘进
+ // 每一帧,弹窗入退场时会跳到视口左上角(位移一半宽高)。故共享动画
+ // 保持 translate + scale,不得删除。
'confirm-content-in': {
from: { opacity: '0', transform: 'translate(-50%, -50%) scale(0.95)' },
to: { opacity: '1', transform: 'translate(-50%, -50%) scale(1)' },
@@ -121,6 +126,18 @@ const config: Config = {
from: { opacity: '1', transform: 'translate(-50%, -50%) scale(1)' },
to: { opacity: '0', transform: 'translate(-50%, -50%) scale(0.95)' },
},
+ // 布局居中弹窗专用(ConfirmDialog 的 inset-0 + m-auto 方案,confirm-dialog.tsx):
+ // keyframes 里不得再带回 translate —— app-region 命中区不跟随 transform,
+ // 入场/退场期间 translate 会把弹窗甩出 no-drag 挖洞。fade + scale 仍按
+ // DESIGN.md §14.4 的 heavy-overlay 规格(250ms in / 150ms out)。
+ 'confirm-content-layout-in': {
+ from: { opacity: '0', transform: 'scale(0.95)' },
+ to: { opacity: '1', transform: 'scale(1)' },
+ },
+ 'confirm-content-layout-out': {
+ from: { opacity: '1', transform: 'scale(1)' },
+ to: { opacity: '0', transform: 'scale(0.95)' },
+ },
},
animation: {
// 功能性 loading spinner 使用 DESIGN.md §14.4 明确登记的语义循环 token;
@@ -144,6 +161,10 @@ const config: Config = {
'confirm-content-in var(--motion-enter, 250ms) cubic-bezier(0, 0, 0.2, 1)',
'confirm-content-out':
'confirm-content-out var(--motion-exit, 150ms) cubic-bezier(0.4, 0, 1, 1)',
+ 'confirm-content-layout-in':
+ 'confirm-content-layout-in var(--motion-enter, 250ms) cubic-bezier(0, 0, 0.2, 1)',
+ 'confirm-content-layout-out':
+ 'confirm-content-layout-out var(--motion-exit, 150ms) cubic-bezier(0.4, 0, 1, 1)',
},
},
},