mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
use multiselect for navidrome tag filters (#1420)
This commit is contained in:
@@ -206,10 +206,10 @@ export const NavidromeAlbumFilters = ({ disableArtistFilter }: NavidromeAlbumFil
|
|||||||
|
|
||||||
interface TagFilterItemProps {
|
interface TagFilterItemProps {
|
||||||
label: string;
|
label: string;
|
||||||
onChange: (value: null | string) => void;
|
onChange: (value: null | string[]) => void;
|
||||||
options: Array<{ id: string; name: string }>;
|
options: Array<{ id: string; name: string }>;
|
||||||
tagValue: string;
|
tagValue: string;
|
||||||
value: string | undefined;
|
value: string | string[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TagFilterItem = ({ label, onChange, options, tagValue, value }: TagFilterItemProps) => {
|
const TagFilterItem = ({ label, onChange, options, tagValue, value }: TagFilterItemProps) => {
|
||||||
@@ -222,15 +222,20 @@ const TagFilterItem = ({ label, onChange, options, tagValue, value }: TagFilterI
|
|||||||
[options],
|
[options],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const defaultValue = useMemo(() => {
|
||||||
|
if (!value) return [];
|
||||||
|
return Array.isArray(value) ? value : [value];
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectWithInvalidData
|
<MultiSelectWithInvalidData
|
||||||
clearable
|
clearable
|
||||||
data={selectData}
|
data={selectData}
|
||||||
defaultValue={value}
|
defaultValue={defaultValue}
|
||||||
key={tagValue}
|
key={tagValue}
|
||||||
label={label}
|
label={label}
|
||||||
limit={100}
|
limit={100}
|
||||||
onChange={onChange}
|
onChange={(e) => (e && e.length > 0 ? onChange(e) : onChange(null))}
|
||||||
searchable
|
searchable
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -257,7 +262,7 @@ const TagFilters = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleTagFilter = useMemo(
|
const handleTagFilter = useMemo(
|
||||||
() => (tag: string, e: null | string) => {
|
() => (tag: string, e: null | string[]) => {
|
||||||
setCustom({ [tag]: e });
|
setCustom({ [tag]: e });
|
||||||
},
|
},
|
||||||
[setCustom],
|
[setCustom],
|
||||||
@@ -289,7 +294,7 @@ const TagFilters = () => {
|
|||||||
onChange={(e) => handleTagFilter(tag.value, e)}
|
onChange={(e) => handleTagFilter(tag.value, e)}
|
||||||
options={tag.options}
|
options={tag.options}
|
||||||
tagValue={tag.value}
|
tagValue={tag.value}
|
||||||
value={query._custom?.[tag.value] as string | undefined}
|
value={query._custom?.[tag.value] as string | string[] | undefined}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user