mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 16:20:03 +00:00
Fix small bug in ComboButton
This commit is contained in:
@@ -26,7 +26,6 @@ export interface ComboButtonProps {
|
|||||||
|
|
||||||
export default function ComboButton({options, preferredOptionKey, description}: ComboButtonProps) {
|
export default function ComboButton({options, preferredOptionKey, description}: ComboButtonProps) {
|
||||||
const [selectedOption, setSelectedOption] = useState(new Set([Object.keys(options)[0]]));
|
const [selectedOption, setSelectedOption] = useState(new Set([Object.keys(options)[0]]));
|
||||||
const [disabledOptions] = useState<string[]>(getDisabledKeys(options));
|
|
||||||
const selectedOptionValue = Array.from(selectedOption)[0];
|
const selectedOptionValue = Array.from(selectedOption)[0];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,11 +50,7 @@ export default function ComboButton({options, preferredOptionKey, description}:
|
|||||||
setSelectedOption(new Set([keys.currentKey]));
|
setSelectedOption(new Set([keys.currentKey]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisabledKeys(options: Record<string, ComboButtonOption>): string[] {
|
return options[selectedOptionValue] && (
|
||||||
return Object.keys(options).filter(key => options[key].isDisabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ButtonGroup className="gap-[1px]">
|
<ButtonGroup className="gap-[1px]">
|
||||||
<Button color="primary" className="w-52"
|
<Button color="primary" className="w-52"
|
||||||
onPress={options[selectedOptionValue].action}>
|
onPress={options[selectedOptionValue].action}>
|
||||||
@@ -74,9 +69,7 @@ export default function ComboButton({options, preferredOptionKey, description}:
|
|||||||
disallowEmptySelection
|
disallowEmptySelection
|
||||||
aria-label="Merge options"
|
aria-label="Merge options"
|
||||||
selectedKeys={selectedOption}
|
selectedKeys={selectedOption}
|
||||||
disabledKeys={disabledOptions}
|
|
||||||
selectionMode="single"
|
selectionMode="single"
|
||||||
/*@ts-ignore*/
|
|
||||||
onSelectionChange={onSelectionChange}
|
onSelectionChange={onSelectionChange}
|
||||||
className="w-60"
|
className="w-60"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user