From 5d0124369ee3a3ddd73e553d3fa5312df2eb4f13 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Fri, 28 Nov 2025 14:39:18 -0800 Subject: [PATCH] fix internalState on expanded album item --- .../components/expanded-album-list-item.tsx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/renderer/features/albums/components/expanded-album-list-item.tsx b/src/renderer/features/albums/components/expanded-album-list-item.tsx index f9a2c95b0..06660556b 100644 --- a/src/renderer/features/albums/components/expanded-album-list-item.tsx +++ b/src/renderer/features/albums/components/expanded-album-list-item.tsx @@ -11,6 +11,7 @@ import { useDefaultItemListControls } from '/@/renderer/components/item-list/hel import { ItemListStateActions, ItemListStateItem, + useItemDraggingState, useItemListState, useItemSelectionState, } from '/@/renderer/components/item-list/helpers/item-list-state'; @@ -30,7 +31,6 @@ import { LibraryItem, Song } from '/@/shared/types/domain-types'; import { DragOperation, DragTarget, DragTargetMap } from '/@/shared/types/drag-and-drop'; interface AlbumTracksTableProps { - internalState?: ItemListStateActions; isDark?: boolean; serverId: string; songs?: Array<{ @@ -57,6 +57,7 @@ interface TrackRowProps { const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) => { const rowId = internalState.extractRowId(song); const isSelected = useItemSelectionState(internalState, rowId); + const isDraggingState = useItemDraggingState(internalState, rowId); const songWithMetadata = { ...song, @@ -101,7 +102,7 @@ const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) => isEnabled: true, }); - const isDragging = internalState.isDragging(song.id) || isDraggingLocal; + const isDragging = isDraggingState || isDraggingLocal; const containerRef = useRef(null); const mergedRef = useMergedRef(containerRef, dragRef); @@ -134,12 +135,7 @@ const TrackRow = ({ controls, internalState, serverId, song }: TrackRowProps) => ); }; -const AlbumTracksTable = ({ - internalState: parentInternalState, - isDark, - serverId, - songs, -}: AlbumTracksTableProps) => { +const AlbumTracksTable = ({ isDark, serverId, songs }: AlbumTracksTableProps) => { const getDataFn = useCallback(() => songs || [], [songs]); const extractRowId = useCallback((item: unknown) => { @@ -149,9 +145,9 @@ const AlbumTracksTable = ({ return undefined; }, []); - // Use parent internalState if available, otherwise create a local one - const localInternalState = useItemListState(getDataFn, extractRowId); - const internalState = parentInternalState || localInternalState; + // Always use a local state for tracks - tracks are separate entities from albums + // and need their own selection state. The parentInternalState is for album-level operations. + const internalState = useItemListState(getDataFn, extractRowId); const controls = useDefaultItemListControls(); @@ -262,7 +258,6 @@ export const ExpandedAlbumListItem = ({ internalState, item }: ExpandedAlbumList