Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from "./debugger-picker.module.scss";
import Select, { SingleValue, OptionsOrGroups, GroupBase } from "react-select";
import { DebuggerPickerOptionModel } from "@/features/common/models/debugger-picker-option.model";
import { LibraryFilterLabel } from "@/features/libraries/models/library-filters.model";
import { isGroupedOptionsType } from "./utils";


interface PickerLabelProps {
Expand All @@ -16,7 +17,7 @@ const getGroupLabel = (
>,
selected: DebuggerPickerOptionModel
): LibraryFilterLabel | undefined => {
if (!Array.isArray(options)) return undefined;
if(!isGroupedOptionsType(options)) return undefined

const group = (options as GroupBase<DebuggerPickerOptionModel>[]).find(
(group) => group.options.some((opt) => opt.value === selected.value)
Expand Down
11 changes: 11 additions & 0 deletions src/features/common/components/debugger-picker/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GroupBase, OptionsOrGroups } from "react-select";
import { DebuggerPickerOptionModel } from "../../models/debugger-picker-option.model";

export const isGroupedOptionsType = (
options: OptionsOrGroups<
DebuggerPickerOptionModel,
GroupBase<DebuggerPickerOptionModel>
>
): options is GroupBase<DebuggerPickerOptionModel>[] => {
return "options" in options[0]
};