From 5dbd514cfcf703543c65e7c2bed3e0d66e154af6 Mon Sep 17 00:00:00 2001 From: Sharlayan <118798881+sharlayan@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:39:54 +0900 Subject: [PATCH] Fix selected account being lost when creating a collection (#39897) --- .../features/collection_adder/index.tsx | 32 ++++++++++++++++--- .../collection_adder/styles.module.scss | 5 +++ .../mastodon/reducers/slices/collections.ts | 7 ++-- 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 app/javascript/mastodon/features/collection_adder/styles.module.scss diff --git a/app/javascript/mastodon/features/collection_adder/index.tsx b/app/javascript/mastodon/features/collection_adder/index.tsx index b1ec2b0375..2045e55fb3 100644 --- a/app/javascript/mastodon/features/collection_adder/index.tsx +++ b/app/javascript/mastodon/features/collection_adder/index.tsx @@ -10,6 +10,7 @@ import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId'; import type { Account } from '@/mastodon/models/account'; import { addCollectionItem, + collectionEditorActions, removeCollectionItem, } from '@/mastodon/reducers/slices/collections'; import CloseIcon from '@/material-icons/400-24px/close.svg?react'; @@ -23,6 +24,7 @@ import { } from '../collections/overview/created_by_account'; import { CollectionToggle } from './collection_toggle'; +import classes from './styles.module.scss'; const messages = defineMessages({ close: { @@ -107,6 +109,23 @@ export const CollectionAdder: React.FC<{ const account = useAppSelector((state) => state.accounts.get(accountId)); const currentAccountId = useCurrentAccountId(); const { collections, status } = useCollectionsCreatedBy(currentAccountId); + const dispatch = useAppDispatch(); + + const handleNewCollection = useCallback(() => { + if (account) { + dispatch( + collectionEditorActions.reset({ + account_id: account.id, + state: + account.feature_approval.current_user === 'manual' + ? 'pending' + : 'accepted', + }), + ); + } + + onClose(); + }, [account, dispatch, onClose]); return (