From bb996d298f56dc78311e1606532011e494bfdcc5 Mon Sep 17 00:00:00 2001 From: CommaBot Date: Tue, 24 Nov 2026 15:31:38 +0800 Subject: [PATCH] fix(mobile): remove the collection edit action (#15897) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mobile collection menu offered "Edit collection", which opens the `collection-editor` dialog, but the mobile dialog registry never registered it (the editor is the desktop dialog and was left commented out when the mobile app got its own dialogs), so tapping it did nothing. This removes the action and the handlers that only served it. A mobile e2e test checks the collection menu no longer offers it. fix #15005 ## Summary by CodeRabbit * **Changes** * Removed the “Edit collection” action from collection menus in mobile navigation. * Collection menus continue to offer rename, add page, favorite, open, split view, and delete actions. Co-authored-by: DarkSky --- .../navigation/nodes/collection/index.tsx | 28 +++-------------- .../nodes/collection/operations.tsx | 31 +++---------------- .../navigation/virtual-scroller/index.tsx | 16 +--------- .../core/src/mobile/dialogs/index.tsx | 1 - .../e2e/explorer-collection.spec.ts | 26 ++++++++++++++++ 5 files changed, 36 insertions(+), 66 deletions(-) create mode 100644 tests/affine-mobile/e2e/explorer-collection.spec.ts diff --git a/packages/frontend/core/src/mobile/components/navigation/nodes/collection/index.tsx b/packages/frontend/core/src/mobile/components/navigation/nodes/collection/index.tsx index b15bd6b407..44b5a2d3d0 100644 --- a/packages/frontend/core/src/mobile/components/navigation/nodes/collection/index.tsx +++ b/packages/frontend/core/src/mobile/components/navigation/nodes/collection/index.tsx @@ -4,7 +4,6 @@ import { type Collection, CollectionService, } from '@affine/core/modules/collection'; -import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import { GlobalContextService } from '@affine/core/modules/global-context'; import { NavigationPanelService } from '@affine/core/modules/navigation-panel'; import { ShareDocsListService } from '@affine/core/modules/share-doc'; @@ -34,12 +33,10 @@ export const NavigationPanelCollectionNode = ({ parentPath: string[]; }) => { const t = useI18n(); - const { globalContextService, collectionService, workspaceDialogService } = - useServices({ - GlobalContextService, - CollectionService, - WorkspaceDialogService, - }); + const { globalContextService, collectionService } = useServices({ + GlobalContextService, + CollectionService, + }); const navigationPanelService = useService(NavigationPanelService); const active = useLiveData(globalContextService.globalContext.collectionId.$) === @@ -63,15 +60,6 @@ export const NavigationPanelCollectionNode = ({ setCollapsed(false); }, [setCollapsed]); - const handleEditCollection = useCallback(() => { - if (!collection) { - return; - } - workspaceDialogService.open('collection-editor', { - collectionId: collection.id, - }); - }, [collection, workspaceDialogService]); - const handleAddDocToCollection = useNavigationPanelCollectionAddDoc( collectionId, handleOpenCollapsed @@ -81,16 +69,10 @@ export const NavigationPanelCollectionNode = ({ ), - [ - additionalOperations, - collectionId, - handleAddDocToCollection, - handleEditCollection, - ] + [additionalOperations, collectionId, handleAddDocToCollection] ); if (!collection) { diff --git a/packages/frontend/core/src/mobile/components/navigation/nodes/collection/operations.tsx b/packages/frontend/core/src/mobile/components/navigation/nodes/collection/operations.tsx index 8d2c3c9ec0..7b522f2a2c 100644 --- a/packages/frontend/core/src/mobile/components/navigation/nodes/collection/operations.tsx +++ b/packages/frontend/core/src/mobile/components/navigation/nodes/collection/operations.tsx @@ -16,7 +16,6 @@ import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; import { DeleteIcon, - FilterIcon, OpenInNewIcon, PlusIcon, SplitViewIcon, @@ -63,8 +62,7 @@ export const useNavigationPanelCollectionAddDoc = ( export const useNavigationPanelCollectionNodeOperations = ( collectionId: string, - handleAddDocToCollection: () => void, - onOpenEdit: () => void + handleAddDocToCollection: () => void ) => { const t = useI18n(); const { @@ -110,10 +108,6 @@ export const useNavigationPanelCollectionNodeOperations = ( }); }, [collectionId, collectionService]); - const handleShowEdit = useCallback(() => { - onOpenEdit(); - }, [onOpenEdit]); - const handleRename = useCallback( (name: string) => { const collection = collectionService.collection$(collectionId).value; @@ -138,7 +132,6 @@ export const useNavigationPanelCollectionNodeOperations = ( handleDeleteCollection, handleOpenInNewTab, handleOpenInSplitView, - handleShowEdit, handleToggleFavoriteCollection, handleRename, }), @@ -149,7 +142,6 @@ export const useNavigationPanelCollectionNodeOperations = ( handleOpenInNewTab, handleOpenInSplitView, handleRename, - handleShowEdit, handleToggleFavoriteCollection, ] ); @@ -157,8 +149,7 @@ export const useNavigationPanelCollectionNodeOperations = ( export const useNavigationPanelCollectionNodeOperationsMenu = ( collectionId: string, - handleAddDocToCollection: () => void, - onOpenEdit: () => void + handleAddDocToCollection: () => void ): NodeOperation[] => { const t = useI18n(); @@ -168,13 +159,11 @@ export const useNavigationPanelCollectionNodeOperationsMenu = ( handleDeleteCollection, handleOpenInNewTab, handleOpenInSplitView, - handleShowEdit, handleToggleFavoriteCollection, handleRename, } = useNavigationPanelCollectionNodeOperations( collectionId, - handleAddDocToCollection, - onOpenEdit + handleAddDocToCollection ); return useMemo( @@ -202,14 +191,6 @@ export const useNavigationPanelCollectionNodeOperationsMenu = ( index: 11, view: , }, - { - index: 99, - view: ( - } onClick={handleShowEdit}> - {t['com.affine.collection.menu.edit']()} - - ), - }, { index: 99, view: ( @@ -278,7 +259,6 @@ export const useNavigationPanelCollectionNodeOperationsMenu = ( handleOpenInNewTab, handleOpenInSplitView, handleRename, - handleShowEdit, handleToggleFavoriteCollection, t, ] @@ -288,18 +268,15 @@ export const useNavigationPanelCollectionNodeOperationsMenu = ( export const NavigationPanelCollectionNodeMenu = ({ collectionId, handleAddDocToCollection, - onOpenEdit, additionalOperations, }: { collectionId: string; handleAddDocToCollection: () => void; - onOpenEdit: () => void; additionalOperations?: NodeOperation[]; }) => { const operations = useNavigationPanelCollectionNodeOperationsMenu( collectionId, - handleAddDocToCollection, - onOpenEdit + handleAddDocToCollection ); const allOperations = useMemo( () => [...(additionalOperations ?? []), ...operations], diff --git a/packages/frontend/core/src/mobile/components/navigation/virtual-scroller/index.tsx b/packages/frontend/core/src/mobile/components/navigation/virtual-scroller/index.tsx index b8bff42f3e..9195b4e597 100644 --- a/packages/frontend/core/src/mobile/components/navigation/virtual-scroller/index.tsx +++ b/packages/frontend/core/src/mobile/components/navigation/virtual-scroller/index.tsx @@ -2,7 +2,6 @@ import { MenuItem, SafeArea, usePromptModal } from '@affine/component'; import { usePageHelper } from '@affine/core/blocksuite/block-suite-page-list/utils'; import { NavigationPanelTreeRoot } from '@affine/core/desktop/components/navigation-panel'; import { CollectionService } from '@affine/core/modules/collection'; -import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import { FavoriteService } from '@affine/core/modules/favorite'; import { NavigationPanelService } from '@affine/core/modules/navigation-panel'; import { OrganizeService } from '@affine/core/modules/organize'; @@ -236,28 +235,15 @@ const CollectionRow = ({ entry: MobileShellNavigationEntry; toggle: () => void; }) => { - const { collectionService, workspaceDialogService } = useServices({ - CollectionService, - WorkspaceDialogService, - }); const expand = useCallback(() => { if (!row.expanded) toggle(); }, [row.expanded, toggle]); const handleAdd = useNavigationPanelCollectionAddDoc(entry.id, expand); - const handleEdit = useCallback(() => { - const collection = collectionService.collection$(entry.id).value; - if (collection) { - workspaceDialogService.open('collection-editor', { - collectionId: entry.id, - }); - } - }, [collectionService, entry.id, workspaceDialogService]); const menuTarget = useMemo( () => ( ), - [entry.id, handleAdd, handleEdit, row.relationId] + [entry.id, handleAdd, row.relationId] ); return ( { + const name = 'Test Collection'; + const section = await expandCollapsibleSection(page, 'collections'); + await section.getByTestId('navigation-panel-bar-add-collection-button').tap(); + await page.getByTestId('prompt-modal-input').fill(name); + await page.getByTestId('prompt-modal-confirm').tap(); + await pageBack(page); + + const collection = section.locator( + `[data-role="navigation-panel-collection"][aria-label="${name}"]` + ); + await expect(collection).toBeVisible(); + + const menu = await openNavigationPanelNodeMenu(page, collection); + await expect(menu.getByText('Delete')).toBeVisible(); + await expect(menu.getByText('Edit collection')).toHaveCount(0); +});