diff --git a/resources/assets/js/composables/useSongList.ts b/resources/assets/js/composables/useSongList.ts index a71f5987..d8883636 100644 --- a/resources/assets/js/composables/useSongList.ts +++ b/resources/assets/js/composables/useSongList.ts @@ -135,9 +135,22 @@ export const useSongList = ( return playables.value } - return sortField.value - ? orderBy(fuzzy.search(filterKeywords.value), extendedSortFields.value!, sortOrder.value) - : fuzzy.search(filterKeywords.value) + const filtered = fuzzy.search(filterKeywords.value) + + if (!sortField.value) { + return filtered + } + + const sortFields = extendedSortFields.value! + + if (sortFields[0] === 'disc' && sortFields.length > 1 && new Set(filtered.map(p => p.disc ?? null)).size === 1) { + // If we're sorting by disc and there's only one disc, we remove disc from the sort fields. + // Otherwise, the tracks will be sorted by disc number first, and since there's only one disc, + // the track order will remain the same through alternating between asc and desc. + sortFields.shift() + } + + return orderBy(filtered, sortFields, sortOrder.value) }) const onPressEnter = async (event: KeyboardEvent) => {