mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 06:27:09 +01:00
[bugfix]: do not change scroll position when focus changes
This commit is contained in:
parent
5f1d0a3b5e
commit
26102bd70a
@ -60,6 +60,7 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
|
||||
const { play } = usePlayerControls();
|
||||
const volume = useVolume();
|
||||
const isFocused = useAppFocus();
|
||||
const isFocusedRef = useRef<boolean>(isFocused);
|
||||
|
||||
useEffect(() => {
|
||||
if (tableRef.current) {
|
||||
@ -211,7 +212,29 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [currentSong, previousSong, tableConfig.followCurrentSong, status, isFocused]);
|
||||
}, [currentSong, previousSong, tableConfig.followCurrentSong, status]);
|
||||
|
||||
// As a separate rule, update the current row when focus changes. This is
|
||||
// to prevent queue scrolling when the application loses and then gains focus.
|
||||
// The body should only fire when focus changes, even though it depends on current song
|
||||
useEffect(() => {
|
||||
if (isFocused !== isFocusedRef.current && tableRef?.current) {
|
||||
const { api, columnApi } = tableRef.current;
|
||||
if (api == null || columnApi == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentNode = currentSong?.uniqueId
|
||||
? api.getRowNode(currentSong.uniqueId)
|
||||
: undefined;
|
||||
|
||||
if (currentNode) {
|
||||
api.redrawRows({ rowNodes: [currentNode] });
|
||||
}
|
||||
|
||||
isFocusedRef.current = isFocused;
|
||||
}
|
||||
}, [currentSong, isFocused]);
|
||||
|
||||
const onCellContextMenu = useHandleTableContextMenu(LibraryItem.SONG, QUEUE_CONTEXT_MENU_ITEMS);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user