From e4953057ef25e692c58e00e5236e908590ee4260 Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Wed, 8 Jan 2025 22:20:18 -0800 Subject: [PATCH] color improvements --- .../void/browser/react/src/util/inputs.tsx | 57 +++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx index 09df6ef8..982469e9 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx @@ -199,13 +199,25 @@ export const VoidCheckBox = ({ label, value, onClick, className }: { label: stri } -export const VoidCustomSelectBox = ({ options, selectedOption, onChangeOption, getOptionName, getOptionsEqual }: { options: T[], selectedOption?: T, onChangeOption: (newValue: T) => void, getOptionName: (option: T) => string, getOptionsEqual: (a: T, b: T) => boolean }) => { - +export const VoidCustomSelectBox = ({ + options, + selectedOption, + onChangeOption, + getOptionName, + getOptionsEqual +}: { + options: T[], + selectedOption?: T, + onChangeOption: (newValue: T) => void, + getOptionName: (option: T) => string, + getOptionsEqual: (a: T, b: T) => boolean +}) => { const [isOpen, setIsOpen] = useState(false); const dropdownRef = useRef(null); + const buttonRef = useRef(null); if (!selectedOption) { - selectedOption = options[0] + selectedOption = options[0]; } useEffect(() => { @@ -218,18 +230,27 @@ export const VoidCustomSelectBox = ({ options, selectedOption, on return () => document.removeEventListener('mousedown', handleClickOutside); }, []); + // Calculate dropdown position + const getDropdownPosition = () => { + if (!buttonRef.current) return { top: 0, left: 0 }; + const rect = buttonRef.current.getBoundingClientRect(); + return { + top: rect.bottom + window.scrollY, + left: rect.left + window.scrollX, + minWidth: rect.width // Ensure dropdown is at least as wide as the button + }; + }; return ( -
+
{/* Select Button */}