fix(ui): reset page to 1 on playlist change - #1676 (#4154)

Signed-off-by: Michael Tighe <strideriidx@gmail.com>
This commit is contained in:
Michael Tighe
2025-05-30 14:28:39 -07:00
committed by GitHub
parent 623919f53e
commit 11c9dd4bd9
+8 -2
View File
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from 'react'
import React, { useCallback, useEffect, useMemo } from 'react'
import {
BulkActionsToolbar,
ListToolbar,
@@ -84,7 +84,8 @@ const ReorderableList = ({ readOnly, children, ...rest }) => {
const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
const listContext = useListContext()
const { data, ids, selectedIds, onUnselectItems, refetch } = listContext
const { data, ids, selectedIds, onUnselectItems, refetch, setPage } =
listContext
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const classes = useStyles({ isDesktop })
const dispatch = useDispatch()
@@ -93,6 +94,11 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
const version = useVersion()
useResourceRefresh('song', 'playlist')
useEffect(() => {
setPage(1)
window.scrollTo({ top: 0, behavior: 'smooth' })
}, [playlistId, setPage])
const onAddToPlaylist = useCallback(
(pls) => {
if (pls.id === playlistId) {