Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(ui): migrate every Drawer call site to base-ui Drawer (#17914)

Innei606c4ee71168
diff --git a/.agents/acceptance/common-mistakes.md b/.agents/acceptance/common-mistakes.md
index 76d74026fc7..5ac3f2b3690 100644
--- a/.agents/acceptance/common-mistakes.md
+++ b/.agents/acceptance/common-mistakes.md
@@ -232,6 +232,30 @@ DOM measurements as well as visual evidence.
## Environment safety
+### L-S0 β€” Concluding a dependency moved from the root manifest alone
+
+**Wrong approach:** refresh a shared dependency by running `pnpm install --filter .`
+at the repo root β€” or by bumping only the root range and running a full install β€”
+then read the new version out of `package.json` and treat a type-check failure in
+untouched files as pre-existing.
+
+**Why it fails:** the filter installs only the root workspace, and even an unfiltered
+install leaves `packages/*` on their old resolution when they declare a loose range
+(`"@lobehub/ui": "^5"` is satisfied by both the old and the new version, so nothing
+forces them to move). Two identities of the same package then coexist in the graph,
+and the errors surface far from the change β€” a duplicated `next` shows up as
+`NextRequest is not assignable to NextRequest` in backend route shells, and a
+duplicated UI package kills routes at the ErrorBoundary with a missing React context,
+or gives a component library two copies of a shared z-index/portal manager. Neither
+names the real cause.
+
+**Correct approach:** run a full `pnpm install` (no filter) after any dependency
+range change, then `pnpm dedupe` when the root and the workspace packages resolve
+different versions of a shared peer. State the version only from resolved copies β€”
+count the versions under `node_modules/<pkg>` and every `packages/*/node_modules/<pkg>`
+and require one distinct value β€” never from the root manifest. Remember `apps/desktop`
+and `apps/cli` are standalone installs that a root install never covers.
+
### L-S1 β€” Publishing to an assumed server target
**Wrong approach:** strip a server environment variable and treat `lh whoami` as
diff --git a/.agents/skills/react/SKILL.md b/.agents/skills/react/SKILL.md
index cf8e80bb9f6..629162ca299 100644
--- a/.agents/skills/react/SKILL.md
+++ b/.agents/skills/react/SKILL.md
@@ -37,6 +37,7 @@ If unsure about available components, search existing code or check `node_module
| `Switch` | `import { Switch } from '@lobehub/ui/base-ui';` |
| `Toast` | `import { Toast } from '@lobehub/ui/base-ui';` |
| `FloatingSheet` | `import { FloatingSheet } from '@lobehub/ui/base-ui';` |
+| `Drawer` | `import { Drawer } from '@lobehub/ui/base-ui';` |
For Modal specifically, see the dedicated **modal** skill β€” use the imperative `createModal({ content: … })` pattern over the legacy `<Modal open … />` declarative pattern. base-ui has its own `ModalHost` already mounted in `SPAGlobalProvider`.
@@ -49,7 +50,7 @@ For Modal specifically, see the dedicated **modal** skill β€” use the imperative
| General | ActionIcon, ActionIconGroup, Block, Button, Icon |
| Data Display | Avatar, Collapse, Empty, Highlighter, Markdown, Tag, Tooltip |
| Data Entry | CodeEditor, CopyButton, EditableText, Form, Input, InputPassword, SearchBar, TextArea |
-| Feedback | Alert, Drawer |
+| Feedback | Alert |
| Layout | Center, DraggablePanel, Flexbox, Grid, Header, MaskShadow |
| Navigation | Burger, Menu, SideNav, Tabs |
diff --git a/AGENTS.md b/AGENTS.md
index 0b9b0b3b9d7..c35a801435e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -7,7 +7,7 @@ Guidelines for using AI coding agents in this opensource LobeHub repository.
- Next.js 16 + React 19 + TypeScript
- SPA inside Next.js with `react-router-dom`
- `@lobehub/ui`, antd for components; antd-style for CSS-in-JS β€” **prefer `createStaticStyles` with `cssVar.*`** (zero-runtime); only fall back to `createStyles` + `token` when styles genuinely need runtime computation. See `.cursor/docs/createStaticStyles_migration_guide.md`.
-- **Component priority**: `@lobehub/ui/base-ui` (headless primitives) **first**, then `@lobehub/ui` root, then antd as last resort. When the component exists in base-ui, use it β€” never reach for the root or antd counterpart. Base-ui covers `Select`, `Modal` / `createModal` / `confirmModal`, `DropdownMenu`, `ContextMenu`, `Popover`, `ScrollArea`, `Switch`, `Toast`, `FloatingSheet`. Prefer `@lobehub/ui/base-ui` for new code and migrate root-package call sites opportunistically.
+- **Component priority**: `@lobehub/ui/base-ui` (headless primitives) **first**, then `@lobehub/ui` root, then antd as last resort. When the component exists in base-ui, use it β€” never reach for the root or antd counterpart. Base-ui covers `Select`, `Modal` / `createModal` / `confirmModal`, `DropdownMenu`, `ContextMenu`, `Popover`, `ScrollArea`, `Switch`, `Toast`, `FloatingSheet`, `Drawer`. Prefer `@lobehub/ui/base-ui` for new code and migrate root-package call sites opportunistically.
- react-i18next for i18n; zustand for state management
- SWR for data fetching; TRPC for type-safe backend
- Drizzle ORM with PostgreSQL; Vitest for testing
diff --git a/package.json b/package.json
index bafc90edfa2..44655b2646d 100644
--- a/package.json
+++ b/package.json
@@ -303,7 +303,7 @@
"@lobehub/icons": "^5.11.0",
"@lobehub/market-sdk": "0.39.2",
"@lobehub/tts": "^5.1.2",
- "@lobehub/ui": "^5.27.0",
+ "@lobehub/ui": "^5.28.0",
"@modelcontextprotocol/sdk": "^1.29.0",
"@napi-rs/canvas": "^0.1.100",
"@neondatabase/serverless": "^1.1.0",
diff --git a/src/components/HtmlPreview/PreviewDrawer.tsx b/src/components/HtmlPreview/PreviewDrawer.tsx
index 161cc4fb822..76cce0001d3 100644
--- a/src/components/HtmlPreview/PreviewDrawer.tsx
+++ b/src/components/HtmlPreview/PreviewDrawer.tsx
@@ -1,8 +1,7 @@
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { exportFile } from '@lobechat/utils/client';
import { Block, Flexbox, Highlighter, HtmlPreview } from '@lobehub/ui';
-import { Button, Tabs } from '@lobehub/ui/base-ui';
-import { Drawer } from 'antd';
+import { Button, Drawer, Tabs } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { Code2, Download, Eye } from 'lucide-react';
import { memo, useCallback, useState } from 'react';
@@ -49,9 +48,8 @@ const HtmlPreviewDrawer = memo<HtmlPreviewDrawerProps>(({ content, open, onClose
exportFile(content, `${base}.html`);
}, [content, extractTitle, sanitizeFileName]);
- const Title = (
- <Flexbox horizontal align={'center'} justify={'space-between'} style={{ width: '100%' }}>
- {t('HtmlPreview.title')}
+ const extra = (
+ <Flexbox horizontal align={'center'} gap={8}>
<Tabs
activeKey={mode}
items={[
@@ -84,13 +82,14 @@ const HtmlPreviewDrawer = memo<HtmlPreviewDrawerProps>(({ content, open, onClose
return (
<Drawer
- destroyOnHidden
+ containerMaxWidth={'100%'}
+ extra={extra}
height={isDesktop ? `calc(100vh - ${TITLE_BAR_HEIGHT}px)` : '100vh'}
open={open}
placement="bottom"
- title={Title}
+ title={t('HtmlPreview.title')}
styles={{
- body: { height: '100%', padding: 0 },
+ bodyContent: { height: '100%', padding: 0 },
header: { paddingBlock: 8, paddingInline: 12 },
}}
onClose={onClose}
diff --git a/src/features/AgentSkillEdit/index.tsx b/src/features/AgentSkillEdit/index.tsx
index 95ade2df614..7890e9b2411 100644
--- a/src/features/AgentSkillEdit/index.tsx
+++ b/src/features/AgentSkillEdit/index.tsx
@@ -3,8 +3,8 @@
import { isDesktop } from '@lobechat/const';
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { type SkillResourceTreeNode } from '@lobechat/types';
-import { Drawer, Flexbox } from '@lobehub/ui';
-import { Button, toast } from '@lobehub/ui/base-ui';
+import { Flexbox } from '@lobehub/ui';
+import { Button, Drawer, toast } from '@lobehub/ui/base-ui';
import { Alert, Form as AForm, Popconfirm, Skeleton } from 'antd';
import { createStaticStyles } from 'antd-style';
import { memo, useMemo, useState } from 'react';
@@ -146,7 +146,6 @@ const AgentSkillEdit = memo<AgentSkillEditProps>(({ skillId, open, onClose }) =>
return (
<Drawer
- destroyOnHidden
containerMaxWidth={'auto'}
footer={footer}
height={isDesktop ? `calc(100vh - ${TITLE_BAR_HEIGHT}px)` : '100vh'}
@@ -155,13 +154,9 @@ const AgentSkillEdit = memo<AgentSkillEditProps>(({ skillId, open, onClose }) =>
push={false}
title={t('agentSkillEdit.title')}
styles={{
- body: { padding: 0 },
- bodyContent: { height: '100%' },
- }}
- onClose={(e) => {
- e.stopPropagation();
- onClose();
+ bodyContent: { height: '100%', padding: 0 },
}}
+ onClose={onClose}
>
{isLoading ? (
<Skeleton active paragraph={{ rows: 8 }} style={{ padding: 16 }} />
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
index 869b65e0f87..e3f47e51055 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
@@ -3,7 +3,6 @@
import {
ActionIcon,
Block,
- Drawer,
type DropdownItem,
DropdownMenu,
Flexbox,
@@ -13,7 +12,7 @@ import {
Text,
TextArea,
} from '@lobehub/ui';
-import { Button, Checkbox, Select, toast } from '@lobehub/ui/base-ui';
+import { Button, Checkbox, Drawer, Select, toast } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import {
ChevronRight,
@@ -751,10 +750,9 @@ const TaskVerifyConfig = memo(() => {
) : null}
</Flexbox>
<Drawer
- destroyOnHidden
open={Boolean(selectedCriterionId)}
placement={'right'}
- styles={{ body: { padding: 0 } }}
+ styles={{ bodyContent: { padding: 0 } }}
title={t('verifyConfig.detail.title')}
width={'min(92vw, 440px)'}
onClose={() => setSelectedCriterionId(null)}
diff --git a/src/features/Electron/connection/Connection.tsx b/src/features/Electron/connection/Connection.tsx
index 45980d932b4..6c0fb6e6a5e 100644
--- a/src/features/Electron/connection/Connection.tsx
+++ b/src/features/Electron/connection/Connection.tsx
@@ -1,6 +1,6 @@
import { Center, Flexbox } from '@lobehub/ui';
-import { Drawer } from 'antd';
-import { createStaticStyles, cssVar } from 'antd-style';
+import { Drawer } from '@lobehub/ui/base-ui';
+import { cssVar } from 'antd-style';
import { Suspense, useCallback } from 'react';
import { BrandTextLoading } from '@/components/Loading';
@@ -12,18 +12,6 @@ import RemoteStatus from './RemoteStatus';
const isMac = isMacOS();
-const styles = createStaticStyles(({ css }) => {
- return {
- modal: css`
- .ant-drawer-close {
- position: absolute;
- inset-block-start: ${isMac ? '12px' : '46px'};
- inset-inline-end: 6px;
- }
- `,
- };
-});
-
const Connection = () => {
const [isOpen, setConnectionDrawerOpen] = useElectronStore((s) => [
s.isConnectionDrawerOpen,
@@ -42,14 +30,18 @@ const Connection = () => {
}}
/>
<Drawer
- classNames={{ header: styles.modal }}
+ noHeader
+ height={'100vh'}
open={isOpen}
placement={'top'}
- size={'100vh'}
- styles={{ body: { padding: 0 }, header: { padding: 0 } }}
style={{
background: cssVar.colorBgLayout,
}}
+ styles={{
+ bodyContent: { padding: 0 },
+ // Clears the Electron title bar, which only overlaps the drawer off macOS.
+ extra: { insetBlockStart: isMac ? 12 : 46, insetInlineEnd: 6 },
+ }}
onClose={handleClose}
>
<Suspense
diff --git a/src/features/NavPanel/SideBarDrawer.tsx b/src/features/NavPanel/SideBarDrawer.tsx
index 75e41d4fd1e..8deae62319e 100644
--- a/src/features/NavPanel/SideBarDrawer.tsx
+++ b/src/features/NavPanel/SideBarDrawer.tsx
@@ -1,11 +1,11 @@
'use client';
import { ActionIcon, Flexbox, Text } from '@lobehub/ui';
-import { Drawer } from 'antd';
-import { cssVar } from 'antd-style';
+import { DrawerPopup, DrawerPortal, DrawerRoot } from '@lobehub/ui/base-ui';
+import { createStaticStyles } from 'antd-style';
import { XIcon } from 'lucide-react';
-import type { ReactNode, Ref } from 'react';
-import { cloneElement, isValidElement, memo, Suspense, useCallback, useState } from 'react';
+import type { ReactNode } from 'react';
+import { memo, Suspense, useEffect, useState } from 'react';
import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
@@ -14,6 +14,30 @@ import { NAV_PANEL_RIGHT_DRAWER_ID } from './constants';
import { OverlayContainerContext } from './OverlayContainer';
import SideBarHeaderLayout from './SideBarHeaderLayout';
+const DRAWER_WIDTH = 280;
+
+// Stays under the base-ui floating tier (1100) so dropdowns and popovers raised
+// from inside the panel still paint above it.
+const DRAWER_Z_INDEX = 1000;
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ body: css`
+ overflow: hidden auto;
+ flex: 1;
+ min-height: 0;
+ background: ${cssVar.colorBgLayout};
+ `,
+ panel: css`
+ border-inline: 1px solid ${cssVar.colorBorderSecondary};
+ background: ${cssVar.colorBgLayout};
+ box-shadow: 4px 0 8px -2px rgb(0 0 0 / 4%);
+ `,
+ popup: css`
+ position: absolute;
+ overflow: hidden;
+ `,
+}));
+
interface SideBarDrawerProps {
action?: ReactNode;
children?: ReactNode;
@@ -23,79 +47,35 @@ interface SideBarDrawerProps {
title?: ReactNode;
}
-interface DrawerRenderNodeProps {
- containerRef?: Ref<HTMLDivElement>;
-}
-
-const setRef = <T,>(ref: Ref<T> | undefined, value: T | null) => {
- if (!ref) return;
-
- if (typeof ref === 'function') {
- ref(value);
- return;
- }
-
- (ref as { current: T | null }).current = value;
-};
-
const SideBarDrawer = memo<SideBarDrawerProps>(
({ subHeader, open, onClose, children, title, action }) => {
- const size = 280;
-
const [overlayContainer, setOverlayContainer] = useState<HTMLDivElement | null>(null);
+ const [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);
- const renderDrawerContent = useCallback((node: ReactNode) => {
- if (!isValidElement<DrawerRenderNodeProps>(node)) return node;
-
- const originalContainerRef = node.props.containerRef;
-
- // Intentionally hook rc-drawer's section ref so dropdown portals stay inside the real drawer content.
- // eslint-disable-next-line @eslint-react/no-clone-element
- return cloneElement(node, {
- containerRef: (instance: HTMLDivElement | null) => {
- setOverlayContainer((current) => (current === instance ? current : instance));
- setRef(originalContainerRef, instance);
- },
- });
+ useEffect(() => {
+ setPortalContainer(document.querySelector<HTMLElement>(`#${NAV_PANEL_RIGHT_DRAWER_ID}`));
}, []);
return (
<OverlayContainerContext value={overlayContainer}>
- <Drawer
- destroyOnHidden
- closable={false}
- drawerRender={renderDrawerContent}
- getContainer={() => document.querySelector(`#${NAV_PANEL_RIGHT_DRAWER_ID}`)!}
- mask={false}
+ <DrawerRoot
+ modal={false}
open={open}
- placement="left"
- size={size}
- rootStyle={{
- bottom: 0,
- overflow: 'hidden',
- position: 'absolute',
- top: 0,
- width: `${size}px`,
+ zIndex={DRAWER_Z_INDEX}
+ onOpenChange={(nextOpen, eventDetails) => {
+ if (nextOpen || eventDetails.reason === 'outside-press') return;
+ onClose();
}}
- styles={{
- body: {
- background: cssVar.colorBgLayout,
- padding: 0,
- },
- header: {
- background: cssVar.colorBgLayout,
- borderBottom: 'none',
- padding: 0,
- },
- wrapper: {
- borderLeft: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRight: `1px solid ${cssVar.colorBorderSecondary}`,
- boxShadow: `4px 0 8px -2px rgba(0,0,0,.04)`,
- zIndex: 0,
- },
- }}
- title={
- <>
+ >
+ <DrawerPortal container={portalContainer}>
+ <DrawerPopup
+ flush
+ className={styles.popup}
+ panelClassName={styles.panel}
+ placement={'left'}
+ ref={setOverlayContainer}
+ width={DRAWER_WIDTH}
+ >
<SideBarHeaderLayout
showBack={false}
showTogglePanelButton={false}
@@ -126,20 +106,20 @@ const SideBarDrawer = memo<SideBarDrawerProps>(
}
/>
{subHeader}
- </>
- }
- onClose={onClose}
- >
- <Suspense
- fallback={
- <Flexbox gap={1} paddingBlock={1} paddingInline={4}>
- <SkeletonList rows={3} />
- </Flexbox>
- }
- >
- {children}
- </Suspense>
- </Drawer>
+ <div className={styles.body}>
+ <Suspense
+ fallback={
+ <Flexbox gap={1} paddingBlock={1} paddingInline={4}>
+ <SkeletonList rows={3} />
+ </Flexbox>
+ }
+ >
+ {children}
+ </Suspense>
+ </div>
+ </DrawerPopup>
+ </DrawerPortal>
+ </DrawerRoot>
</OverlayContainerContext>
);
},
diff --git a/src/features/PluginDevModal/index.tsx b/src/features/PluginDevModal/index.tsx
index 5bb8049ce62..95716082448 100644
--- a/src/features/PluginDevModal/index.tsx
+++ b/src/features/PluginDevModal/index.tsx
@@ -1,8 +1,8 @@
import { isDesktop } from '@lobechat/const';
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { type LobeToolCustomPlugin } from '@lobechat/types';
-import { Drawer, Flexbox } from '@lobehub/ui';
-import { Button, toast } from '@lobehub/ui/base-ui';
+import { Flexbox } from '@lobehub/ui';
+import { Button, Drawer, toast } from '@lobehub/ui/base-ui';
import { Form, Popconfirm } from 'antd';
import { useResponsive } from 'antd-style';
import { memo, useEffect, useRef, useState } from 'react';
@@ -168,7 +168,6 @@ const DevModal = memo<DevModalProps>(
}}
>
<Drawer
- destroyOnHidden
containerMaxWidth={'auto'}
footer={footer}
height={isDesktop ? `calc(100vh - ${TITLE_BAR_HEIGHT}px)` : '100vh'}
@@ -177,21 +176,13 @@ const DevModal = memo<DevModalProps>(
push={false}
title={t(isEditMode ? 'dev.title.skillSettings' : 'dev.title.create')}
width={mobile ? '100%' : 800}
- // Sit above @lobehub/ui's base-ui floating layer (Popover/Dropdown/Tooltip = 1100).
- // antd Drawer defaults to ~1000, so a config panel opened from the Tools skill
- // popover would otherwise mount *behind* the still-open popover and look like it
- // "didn't open". 1200 = the base-ui modal tier.
- zIndex={1200}
styles={{
- body: {
- padding: 0,
- },
bodyContent: {
height: '100%',
+ padding: 0,
},
}}
- onClose={(e) => {
- e.stopPropagation();
+ onClose={() => {
onOpenChange(false);
}}
>
diff --git a/src/features/ResourceManager/components/ChunkDrawer/index.tsx b/src/features/ResourceManager/components/ChunkDrawer/index.tsx
index 935c4743fe0..d67f93b6f7e 100644
--- a/src/features/ResourceManager/components/ChunkDrawer/index.tsx
+++ b/src/features/ResourceManager/components/ChunkDrawer/index.tsx
@@ -1,5 +1,5 @@
import { Flexbox } from '@lobehub/ui';
-import { Drawer } from 'antd';
+import { Drawer } from '@lobehub/ui/base-ui';
import { cssVar } from 'antd-style';
import { memo } from 'react';
@@ -24,10 +24,10 @@ const ChunkDrawer = memo(() => {
return (
<Drawer
open={open}
- size="large"
title={file?.name}
+ width={736}
styles={{
- body: { padding: 0 },
+ bodyContent: { height: '100%', padding: 0 },
}}
onClose={() => {
closeChunkDrawer();
diff --git a/src/features/Verify/Acceptance/FeedbackDrawer.tsx b/src/features/Verify/Acceptance/FeedbackDrawer.tsx
index 9eddb445f58..32257183263 100644
--- a/src/features/Verify/Acceptance/FeedbackDrawer.tsx
+++ b/src/features/Verify/Acceptance/FeedbackDrawer.tsx
@@ -1,7 +1,8 @@
'use client';
import type { AcceptanceAttachment } from '@lobechat/types';
-import { Drawer, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import { Drawer } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import dayjs from 'dayjs';
import { memo } from 'react';
diff --git a/src/features/Verify/Acceptance/attachments.test.tsx b/src/features/Verify/Acceptance/attachments.test.tsx
new file mode 100644
index 00000000000..c2d7f94606c
--- /dev/null
+++ b/src/features/Verify/Acceptance/attachments.test.tsx
@@ -0,0 +1,64 @@
+import { cleanup, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { AttachmentThumbs } from './attachments';
+
+// The unit env has neither the MotionProvider nor the image-preview portal the real
+// components need; stub them down to the DOM the assertions actually read.
+vi.mock('@lobehub/ui', () => ({
+ Flexbox: ({ children, onClick }: any) => <div onClick={onClick}>{children}</div>,
+ Icon: () => null,
+ Image: ({ alt, src }: any) => <img alt={alt} src={src} />,
+}));
+
+vi.mock('@lobehub/ui/base-ui', () => ({
+ Button: ({ children, onClick }: any) => (
+ <button type="button" onClick={onClick}>
+ {children}
+ </button>
+ ),
+ toast: { error: vi.fn(), success: vi.fn() },
+}));
+
+vi.mock('antd', () => ({ Upload: ({ children }: any) => <div>{children}</div> }));
+
+vi.mock('@/store/file', () => ({ useFileStore: () => vi.fn() }));
+
+const attachments = [{ id: 'att-1', name: 'screenshot.png', url: 'https://example.com/a.png' }];
+
+afterEach(cleanup);
+
+describe('AttachmentThumbs', () => {
+ it('does not trigger the host row while zooming a thumbnail', async () => {
+ // The feedback/check row wrapping this list is itself clickable and its handler
+ // closes the surrounding drawer, which unmounts the zoom viewer in the tick it
+ // opens. Zooming has to stay its own action.
+ const onRowClick = vi.fn();
+
+ render(
+ <div onClick={onRowClick}>
+ <AttachmentThumbs attachments={attachments} />
+ </div>,
+ );
+
+ await userEvent.click(screen.getByRole('img'));
+
+ expect(onRowClick).not.toHaveBeenCalled();
+ });
+
+ it('still lets the host row handle clicks outside the thumbnails', async () => {
+ const onRowClick = vi.fn();
+
+ render(
+ <div onClick={onRowClick}>
+ <span>row body</span>
+ <AttachmentThumbs attachments={attachments} />
+ </div>,
+ );
+
+ await userEvent.click(screen.getByText('row body'));
+
+ expect(onRowClick).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/src/features/Verify/Acceptance/attachments.tsx b/src/features/Verify/Acceptance/attachments.tsx
index ded857ee177..bec5e2e1d65 100644
--- a/src/features/Verify/Acceptance/attachments.tsx
+++ b/src/features/Verify/Acceptance/attachments.tsx
@@ -239,7 +239,17 @@ export const AttachmentThumbs = memo<AttachmentThumbsProps>(({ attachments }) =>
const usable = (attachments ?? []).filter((attachment) => attachment.url);
if (usable.length === 0) return null;
return (
- <Flexbox horizontal gap={6} wrap={'wrap'}>
+ // Every host row is itself clickable (jump to the check), and that jump closes the
+ // drawer this list often lives in β€” which would unmount the zoom viewer in the same
+ // tick it opened. Zooming a thumbnail is its own action, so it stops here.
+ <Flexbox
+ horizontal
+ gap={6}
+ wrap={'wrap'}
+ onClick={(event) => {
+ event.stopPropagation();
+ }}
+ >
{usable.map((attachment) => (
<div className={styles.thumb} key={attachment.id}>
<Image alt={attachment.name ?? ''} src={attachment.url!} />
diff --git a/src/features/Verify/ReportViewer.tsx b/src/features/Verify/ReportViewer.tsx
index 3021f1c5635..d57c1d40063 100644
--- a/src/features/Verify/ReportViewer.tsx
+++ b/src/features/Verify/ReportViewer.tsx
@@ -13,8 +13,8 @@ import type {
VerifyVerdict,
} from '@lobechat/types';
import { toRecord } from '@lobechat/utils/object';
-import { Block, Center, Drawer, Empty, Flexbox, Icon, Image, Markdown, Text } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
+import { Block, Center, Empty, Flexbox, Icon, Image, Markdown, Text } from '@lobehub/ui';
+import { Button, Drawer } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import type { TFunction } from 'i18next';
import {
@@ -1307,21 +1307,17 @@ const EvidenceDrawer = memo<{
title: string;
}>(({ evidence, onClose, open, title }) => (
<Drawer
- destroyOnHidden
containerMaxWidth={'100%'}
open={open}
placement={'right'}
title={title}
width={'min(1120px, calc(100vw - 48px))'}
styles={{
- body: {
- height: '100%',
- padding: 0,
- },
bodyContent: {
height: '100%',
minHeight: 0,
overflow: 'hidden',
+ padding: 0,
},
}}
onClose={onClose}
diff --git a/src/features/Verify/components/MarkdownEvidence.tsx b/src/features/Verify/components/MarkdownEvidence.tsx
index 980ddc8ade9..ef2325210e2 100644
--- a/src/features/Verify/components/MarkdownEvidence.tsx
+++ b/src/features/Verify/components/MarkdownEvidence.tsx
@@ -1,16 +1,7 @@
'use client';
-import {
- Center,
- Drawer,
- Flexbox,
- Highlighter,
- Icon,
- Markdown,
- MaskShadow,
- Text,
-} from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
+import { Center, Flexbox, Highlighter, Icon, Markdown, MaskShadow, Text } from '@lobehub/ui';
+import { Button, Drawer } from '@lobehub/ui/base-ui';
import { useSize } from 'ahooks';
import { createStaticStyles, cssVar } from 'antd-style';
import { ChevronsDownUpIcon, ChevronsUpDownIcon, FileText } from 'lucide-react';
@@ -235,15 +226,13 @@ export const EvidenceFileCard = memo<{
</button>
{open && (
<Drawer
- destroyOnHidden
containerMaxWidth={'100%'}
open={open}
placement={'right'}
title={name}
width={'min(1120px, calc(100vw - 48px))'}
styles={{
- body: { height: '100%', padding: 0 },
- bodyContent: { height: '100%', minHeight: 0, overflow: 'hidden' },
+ bodyContent: { height: '100%', minHeight: 0, overflow: 'hidden', padding: 0 },
}}
onClose={() => setOpen(false)}
>
diff --git a/src/routes/(mobile)/community/(list)/_layout/Nav.tsx b/src/routes/(mobile)/community/(list)/_layout/Nav.tsx
index 69c6d2b14b6..cf65c8d5cd5 100644
--- a/src/routes/(mobile)/community/(list)/_layout/Nav.tsx
+++ b/src/routes/(mobile)/community/(list)/_layout/Nav.tsx
@@ -1,7 +1,7 @@
'use client';
import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { Drawer } from 'antd';
+import { Drawer } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import { MenuIcon } from 'lucide-react';
import { memo, useState } from 'react';
@@ -60,25 +60,20 @@ const Nav = memo(() => {
</Flexbox>
<Drawer
- headerStyle={{ display: 'none' }}
+ noHeader
+ closable={false}
open={open}
placement={'left'}
- rootStyle={{ position: 'absolute' }}
width={260}
zIndex={10}
- bodyStyle={{
- display: 'flex',
- flexDirection: 'column',
- gap: 20,
- justifyContent: 'space-between',
- padding: 16,
- }}
style={{
background: cssVar.colorBgLayout,
borderRight: `1px solid ${cssVar.colorSplit}`,
paddingTop: 44,
}}
- onClick={() => setOpen(false)}
+ styles={{
+ bodyContent: { gap: 20, justifyContent: 'space-between', padding: 16 },
+ }}
onClose={() => setOpen(false)}
>
<Menu
@@ -93,6 +88,7 @@ const Nav = memo(() => {
} else {
navigate(`/community/${key}`);
}
+ setOpen(false);
}}
/>
</Drawer>