From db0339b228ce0b5b60ad66dcd27befb4d9ae3d95 Mon Sep 17 00:00:00 2001 From: Prathmesh Vhatkar Date: Tue, 28 Jan 2025 20:15:52 +0530 Subject: [PATCH 1/2] fix: Use Dropdown instead of select in settings for more ui consistency --- .../components/settings/ApiConfigManager.tsx | 32 +++++++---------- .../src/components/settings/SettingsView.tsx | 34 +++++++++---------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/webview-ui/src/components/settings/ApiConfigManager.tsx b/webview-ui/src/components/settings/ApiConfigManager.tsx index 0a60f60..907043f 100644 --- a/webview-ui/src/components/settings/ApiConfigManager.tsx +++ b/webview-ui/src/components/settings/ApiConfigManager.tsx @@ -1,6 +1,8 @@ import { VSCodeButton, VSCodeTextField } from "@vscode/webview-ui-toolkit/react" import { memo, useEffect, useRef, useState } from "react" import { ApiConfigMeta } from "../../../../src/shared/ExtensionMessage" +import { Dropdown } from "vscrui" +import type { DropdownOption } from "vscrui" interface ApiConfigManagerProps { currentApiConfigName?: string @@ -133,28 +135,20 @@ const ApiConfigManager = ({ ) : ( <>
- + minWidth: 130, + }} + options={listApiConfigMeta.map((config) => ({ + value: config.name, + label: config.name, + }))} + /> void @@ -444,23 +446,21 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {

Browser Settings

- +
+ { + setBrowserViewportSize((value as DropdownOption).value) + }} + style={{ width: "100%" }} + options={[ + { value: "1280x800", label: "Large Desktop (1280x800)" }, + { value: "900x600", label: "Small Desktop (900x600)" }, + { value: "768x1024", label: "Tablet (768x1024)" }, + { value: "360x640", label: "Mobile (360x640)" }, + ]} + /> +

Date: Wed, 29 Jan 2025 09:14:16 +0530 Subject: [PATCH 2/2] fix: Mock dropdown in tests correctly --- .../src/components/settings/ApiConfigManager.tsx | 1 + .../settings/__tests__/ApiConfigManager.test.tsx | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/webview-ui/src/components/settings/ApiConfigManager.tsx b/webview-ui/src/components/settings/ApiConfigManager.tsx index 907043f..8bbd588 100644 --- a/webview-ui/src/components/settings/ApiConfigManager.tsx +++ b/webview-ui/src/components/settings/ApiConfigManager.tsx @@ -144,6 +144,7 @@ const ApiConfigManager = ({ style={{ minWidth: 130, }} + role="combobox" options={listApiConfigMeta.map((config) => ({ value: config.name, label: config.name, diff --git a/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx b/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx index 784d443..ec076dd 100644 --- a/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx +++ b/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx @@ -19,6 +19,20 @@ jest.mock("@vscode/webview-ui-toolkit/react", () => ({ ), })) +jest.mock("vscrui", () => ({ + Dropdown: ({ id, value, onChange, options, role }: any) => ( +

+ +
+ ), +})) + describe("ApiConfigManager", () => { const mockOnSelectConfig = jest.fn() const mockOnDeleteConfig = jest.fn()