Elffuss BraidHub

kikocis/continue public

fix: close the model select dropdown automatically (#7943)

Changesete42b01d8d894d554c481be83cc5925a86181ba235a1119f48792ca942e74e39b
AuthorAditya Mitra <61635505+uinstinct@users.noreply.github.com> · 2025-09-24 22:36 +05:30
CommitterGitHub <noreply@github.com> · 2025-09-24 10:06 -07:00
Parents53ff866ea6e7

Browse the files at this changeset

1 file changed

modified gui/src/components/modelSelection/ModelSelect.tsx +13 −12
@@ -5,17 +5,15 @@
55 CubeIcon,
66 PlusIcon,
77 } from "@heroicons/react/24/outline";
8-import { useContext, useEffect, useRef, useState } from "react";
8+import { useEffect, useRef, useState } from "react";
99 import { useNavigate } from "react-router-dom";
1010 import { useAuth } from "../../context/Auth";
11-import { IdeMessengerContext } from "../../context/IdeMessenger";
1211 import { AddModelForm } from "../../forms/AddModelForm";
1312 import { useAppDispatch, useAppSelector } from "../../redux/hooks";
1413 import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
1514 import { updateSelectedModelByRole } from "../../redux/thunks/updateSelectedModelByRole";
1615 import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
1716 import { CONFIG_ROUTES } from "../../util/navigation";
18-import { ToolTip } from "../gui/Tooltip";
1917 import {
2018 Button,
2119 Listbox,
@@ -52,6 +50,15 @@
5250 return model?.class_name;
5351 }
5452
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+
5562 function ModelOption({
5663 option,
5764 idx,
@@ -117,7 +124,6 @@
117124 const isInEdit = useAppSelector((store) => store.session.isInEdit);
118125 const config = useAppSelector((state) => state.config.config);
119126 const isConfigLoading = useAppSelector((state) => state.config.loading);
120- const ideMessenger = useContext(IdeMessengerContext);
121127 const buttonRef = useRef<HTMLButtonElement>(null);
122128 const [options, setOptions] = useState<Option[]>([]);
123129 const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
@@ -201,10 +207,8 @@
201207 e.stopPropagation();
202208 e.preventDefault();
203209
204- // Close the dropdown
205- if (buttonRef.current) {
206- buttonRef.current.click();
207- }
210+ closeDropDown(buttonRef.current);
211+
208212 dispatch(setShowDialog(true));
209213 dispatch(
210214 setDialogMessage(
@@ -221,10 +225,7 @@
221225 e.stopPropagation();
222226 e.preventDefault();
223227
224- // Close the dropdown
225- if (buttonRef.current) {
226- buttonRef.current.click();
227- }
228+ closeDropDown(buttonRef.current);
228229
229230 navigate(CONFIG_ROUTES.MODELS);
230231 }