From a162397d290de2a07e5cf7cee02b1169495b5efb Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Tue, 3 Jun 2025 12:39:08 +0300 Subject: [PATCH] refactor(MultiselectMenu): lint & types --- .../MultiselectMenu/Dropdown/Dropdown.tsx | 6 +++--- .../MultiselectMenu/Dropdown/Option/Option.tsx | 4 ++-- .../MultiselectMenu/MultiselectMenu.tsx | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/MultiselectMenu/Dropdown/Dropdown.tsx b/src/components/MultiselectMenu/Dropdown/Dropdown.tsx index 5f1ee4fa0..411ef6ab5 100644 --- a/src/components/MultiselectMenu/Dropdown/Dropdown.tsx +++ b/src/components/MultiselectMenu/Dropdown/Dropdown.tsx @@ -10,11 +10,11 @@ import styles from './Dropdown.less'; type Props = { options: MultiselectMenuOption[]; - value?: string | number | null; + value?: string | number; menuOpen: boolean | (() => void); level: number; setLevel: (level: number) => void; - onSelect: (value: string | number | null) => void; + onSelect: (value: string | number) => void; }; const Dropdown = ({ level, setLevel, options, onSelect, value, menuOpen }: Props) => { @@ -22,7 +22,7 @@ const Dropdown = ({ level, setLevel, options, onSelect, value, menuOpen }: Props const optionsRef = useRef(new Map()); const containerRef = useRef(null); - const selectedOption = options.find(opt => opt.value === value) || null; + const selectedOption = options.find((opt) => opt.value === value); const handleSetOptionRef = useCallback((optionValue: string | number) => (node: HTMLButtonElement | null) => { if (node) { diff --git a/src/components/MultiselectMenu/Dropdown/Option/Option.tsx b/src/components/MultiselectMenu/Dropdown/Option/Option.tsx index 444e1876e..9ff1480f1 100644 --- a/src/components/MultiselectMenu/Dropdown/Option/Option.tsx +++ b/src/components/MultiselectMenu/Dropdown/Option/Option.tsx @@ -8,8 +8,8 @@ import Icon from '@stremio/stremio-icons/react'; type Props = { option: MultiselectMenuOption; - selectedValue?: string | number | null; - onSelect: (value: string | number | null) => void; + selectedValue?: string | number; + onSelect: (value: string | number) => void; }; const Option = forwardRef(({ option, selectedValue, onSelect }, ref) => { diff --git a/src/components/MultiselectMenu/MultiselectMenu.tsx b/src/components/MultiselectMenu/MultiselectMenu.tsx index 9a84cb8eb..4fef5ce81 100644 --- a/src/components/MultiselectMenu/MultiselectMenu.tsx +++ b/src/components/MultiselectMenu/MultiselectMenu.tsx @@ -13,8 +13,8 @@ type Props = { className?: string, title?: string | (() => string); options: MultiselectMenuOption[]; - value?: string | number | null; - onSelect: (value: string | number | null) => void; + value?: string | number; + onSelect: (value: string | number) => void; }; const MultiselectMenu = ({ className, title, options, value, onSelect }: Props) => { @@ -22,9 +22,9 @@ const MultiselectMenu = ({ className, title, options, value, onSelect }: Props) const multiselectMenuRef = useOutsideClick(() => closeMenu()); const [level, setLevel] = React.useState(0); - const selectedOption = options.find(opt => opt.value === value); + const selectedOption = options.find((opt) => opt.value === value); - const onOptionSelect = (selectedValue: string | number | null) => { + const onOptionSelect = (selectedValue: string | number) => { level ? setLevel(level + 1) : onSelect(selectedValue), closeMenu(); }; @@ -38,11 +38,11 @@ const MultiselectMenu = ({ className, title, options, value, onSelect }: Props) aria-expanded={menuOpen} >
- { - typeof title === 'function' - ? title() - : title ?? selectedOption?.label - } + { + typeof title === 'function' + ? title() + : title ?? selectedOption?.label + }