Changesets · Branches · Tags · Compare
| Changeset | e42b01d8d894d554c481be83cc5925a86181ba235a1119f48792ca942e74e39b |
|---|---|
| Author | Aditya Mitra <61635505+uinstinct@users.noreply.github.com> · 2025-09-24 22:36 +05:30 |
| Committer | GitHub <noreply@github.com> · 2025-09-24 10:06 -07:00 |
| Parents | 53ff866ea6e7 |
1 file changed
modified gui/src/components/modelSelection/ModelSelect.tsx +13 −12
| @@ -5,17 +5,15 @@ | ||
| 5 | 5 | CubeIcon, |
| 6 | 6 | PlusIcon, |
| 7 | 7 | } from "@heroicons/react/24/outline"; |
| 8 | -import { useContext, useEffect, useRef, useState } from "react"; | |
| 8 | +import { useEffect, useRef, useState } from "react"; | |
| 9 | 9 | import { useNavigate } from "react-router-dom"; |
| 10 | 10 | import { useAuth } from "../../context/Auth"; |
| 11 | -import { IdeMessengerContext } from "../../context/IdeMessenger"; | |
| 12 | 11 | import { AddModelForm } from "../../forms/AddModelForm"; |
| 13 | 12 | import { useAppDispatch, useAppSelector } from "../../redux/hooks"; |
| 14 | 13 | import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; |
| 15 | 14 | import { updateSelectedModelByRole } from "../../redux/thunks/updateSelectedModelByRole"; |
| 16 | 15 | import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; |
| 17 | 16 | import { CONFIG_ROUTES } from "../../util/navigation"; |
| 18 | -import { ToolTip } from "../gui/Tooltip"; | |
| 19 | 17 | import { |
| 20 | 18 | Button, |
| 21 | 19 | Listbox, |
| @@ -52,6 +50,15 @@ | ||
| 52 | 50 | return model?.class_name; |
| 53 | 51 | } |
| 54 | 52 | |
| 53 | +/**makeshift way to close the headlessui listbox due to absence of open state on the listbox */ | |
| 54 | +function closeDropDown(button: HTMLButtonElement | null) { | |
| 55 | + if (!button) return; | |
| 56 | + button.classList.add("hidden"); | |
| 57 | + setTimeout(() => { | |
| 58 | + button.classList.remove("hidden"); | |
| 59 | + }); | |
| 60 | +} | |
| 61 | + | |
| 55 | 62 | function ModelOption({ |
| 56 | 63 | option, |
| 57 | 64 | idx, |
| @@ -117,7 +124,6 @@ | ||
| 117 | 124 | const isInEdit = useAppSelector((store) => store.session.isInEdit); |
| 118 | 125 | const config = useAppSelector((state) => state.config.config); |
| 119 | 126 | const isConfigLoading = useAppSelector((state) => state.config.loading); |
| 120 | - const ideMessenger = useContext(IdeMessengerContext); | |
| 121 | 127 | const buttonRef = useRef<HTMLButtonElement>(null); |
| 122 | 128 | const [options, setOptions] = useState<Option[]>([]); |
| 123 | 129 | const [sortedOptions, setSortedOptions] = useState<Option[]>([]); |
| @@ -201,10 +207,8 @@ | ||
| 201 | 207 | e.stopPropagation(); |
| 202 | 208 | e.preventDefault(); |
| 203 | 209 | |
| 204 | - // Close the dropdown | |
| 205 | - if (buttonRef.current) { | |
| 206 | - buttonRef.current.click(); | |
| 207 | - } | |
| 210 | + closeDropDown(buttonRef.current); | |
| 211 | + | |
| 208 | 212 | dispatch(setShowDialog(true)); |
| 209 | 213 | dispatch( |
| 210 | 214 | setDialogMessage( |
| @@ -221,10 +225,7 @@ | ||
| 221 | 225 | e.stopPropagation(); |
| 222 | 226 | e.preventDefault(); |
| 223 | 227 | |
| 224 | - // Close the dropdown | |
| 225 | - if (buttonRef.current) { | |
| 226 | - buttonRef.current.click(); | |
| 227 | - } | |
| 228 | + closeDropDown(buttonRef.current); | |
| 228 | 229 | |
| 229 | 230 | navigate(CONFIG_ROUTES.MODELS); |
| 230 | 231 | } |