mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
add hotkey to album search input
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { ReactNode, Suspense, useMemo, useState } from 'react';
|
import { ReactNode, Suspense, useMemo, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { generatePath, useParams } from 'react-router';
|
import { generatePath, useParams } from 'react-router';
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ import { Spoiler } from '/@/shared/components/spoiler/spoiler';
|
|||||||
import { Stack } from '/@/shared/components/stack/stack';
|
import { Stack } from '/@/shared/components/stack/stack';
|
||||||
import { TextInput } from '/@/shared/components/text-input/text-input';
|
import { TextInput } from '/@/shared/components/text-input/text-input';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
|
import { useHotkeys } from '/@/shared/hooks/use-hotkeys';
|
||||||
import {
|
import {
|
||||||
Album,
|
Album,
|
||||||
AlbumListSort,
|
AlbumListSort,
|
||||||
@@ -579,6 +580,19 @@ const AlbumDetailSongsTable = ({ songs }: AlbumDetailSongsTableProps) => {
|
|||||||
};
|
};
|
||||||
}, [player]);
|
}, [player]);
|
||||||
|
|
||||||
|
const binding = useSettingsStore((state) => state.hotkeys.bindings.localSearch);
|
||||||
|
|
||||||
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
useHotkeys([
|
||||||
|
[
|
||||||
|
binding.hotkey,
|
||||||
|
() => {
|
||||||
|
searchInputRef.current?.focus();
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
if (!tableConfig || columns.length === 0) {
|
if (!tableConfig || columns.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -594,6 +608,7 @@ const AlbumDetailSongsTable = ({ songs }: AlbumDetailSongsTableProps) => {
|
|||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
placeholder={t('common.search', { postProcess: 'sentenceCase' })}
|
placeholder={t('common.search', { postProcess: 'sentenceCase' })}
|
||||||
radius="xl"
|
radius="xl"
|
||||||
|
ref={searchInputRef}
|
||||||
rightSection={
|
rightSection={
|
||||||
searchTerm ? (
|
searchTerm ? (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user