Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📐 feat: Give Dropdown the Positioning Props DropdownPopup Takes (#17461)
Marco Beretta19ba23e0574e
diff --git a/client/src/components/Audio/Voices.tsx b/client/src/components/Audio/Voices.tsxindex d62a72b215..5c4530c199 100644--- a/client/src/components/Audio/Voices.tsx+++ b/client/src/components/Audio/Voices.tsx@@ -29,7 +29,8 @@ export function BrowserVoiceDropdown({ disabled = false }: { disabled?: booleanvalue={voice ?? ''}options={voices}onChange={handleVoiceChange}- sizeClasses="z-50 min-w-[min(12.5rem,90vw)] max-w-[min(25rem,90vw)]"+ minWidth="12.5rem"+ sizeClasses="max-w-[min(25rem,90vw)]"testId="BrowserVoiceDropdown"className="z-50"aria-labelledby={labelId}@@ -62,7 +63,8 @@ export function ExternalVoiceDropdown({ disabled = false }: { disabled?: booleanvalue={voice ?? ''}options={voices}onChange={handleVoiceChange}- sizeClasses="z-50 min-w-[min(12.5rem,90vw)] max-w-[min(25rem,90vw)]"+ minWidth="12.5rem"+ sizeClasses="max-w-[min(25rem,90vw)]"testId="ExternalVoiceDropdown"className="z-50"aria-labelledby={labelId}diff --git a/client/src/components/Nav/Settings/CodeEnvironments.tsx b/client/src/components/Nav/Settings/CodeEnvironments.tsxindex 9d6d1034c7..98534ee86f 100644--- a/client/src/components/Nav/Settings/CodeEnvironments.tsx+++ b/client/src/components/Nav/Settings/CodeEnvironments.tsx@@ -83,7 +83,7 @@ function WorkerCommand({ pairing }: { pairing: CodeEnvironmentPairingResponse['pariaLabel={localize('com_ui_code_environment_shell')}testId="code-environment-shell"className="shrink-0"- sizeClasses="z-50 min-w-48"+ minWidth="12rem"/></div><p className="text-text-secondary text-xs">@@ -192,7 +192,7 @@ function EnvironmentPermissions({ environment }: { environment: TCodeEnvironmentaria-labelledby={`${idPrefix}-${category}`}testId={`code-environment-${category}`}variant="field"- sizeClasses="z-50 min-w-48"+ minWidth="12rem"/></div>);@@ -295,7 +295,7 @@ export default function CodeEnvironments() {aria-labelledby={planeId}testId="code-environment-control-plane"variant="field"- sizeClasses="z-50 min-w-48"+ minWidth="12rem"/></div><Button type="submit" disabled={!name.trim() || pairMutation.isLoading}>diff --git a/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx b/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsxindex 318b219e4d..34347c1c28 100644--- a/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx+++ b/client/src/components/Nav/Settings/StatefulWorkspaceDefault.tsx@@ -79,7 +79,7 @@ export default function StatefulWorkspaceDefault() {aria-labelledby="default-stateful-workspace-label"aria-describedby="default-stateful-workspace-description"className="shrink-0"- sizeClasses="z-50 min-w-[18rem]"+ minWidth="18rem"triggerClassName="w-full sm:w-[16rem]"/></div>diff --git a/client/src/components/Nav/SettingsTabs/Chat/ChatDirection.tsx b/client/src/components/Nav/SettingsTabs/Chat/ChatDirection.tsxindex c8964bca46..038ede35e5 100644--- a/client/src/components/Nav/SettingsTabs/Chat/ChatDirection.tsx+++ b/client/src/components/Nav/SettingsTabs/Chat/ChatDirection.tsx@@ -24,7 +24,7 @@ const ChatDirection = () => {options={options}onChange={(value: string) => setDirection(value as TChatDirection)}testId="chatDirection"- sizeClasses="z-50 w-[9.375rem]"+ sizeClasses="w-[9.375rem]"className="z-50"aria-labelledby={labelId}/>diff --git a/client/src/components/Nav/SettingsTabs/Chat/DuringRunAction.tsx b/client/src/components/Nav/SettingsTabs/Chat/DuringRunAction.tsxindex 3c0704dd48..6dd6d864a4 100644--- a/client/src/components/Nav/SettingsTabs/Chat/DuringRunAction.tsx+++ b/client/src/components/Nav/SettingsTabs/Chat/DuringRunAction.tsx@@ -25,7 +25,6 @@ export default function DuringRunAction() {if (value === 'steer' || value === 'interrupt' || value === 'queue') setAction(value);}}className="z-50"- sizeClasses="z-50"testId="duringRunAction"aria-labelledby={labelId}/>diff --git a/client/src/components/Nav/SettingsTabs/Chat/FontSizeSelector.tsx b/client/src/components/Nav/SettingsTabs/Chat/FontSizeSelector.tsxindex b0b531ad5c..60fd29b5fb 100644--- a/client/src/components/Nav/SettingsTabs/Chat/FontSizeSelector.tsx+++ b/client/src/components/Nav/SettingsTabs/Chat/FontSizeSelector.tsx@@ -29,7 +29,7 @@ export default function FontSizeSelector() {options={options}onChange={handleChange}testId="font-size-selector"- sizeClasses="z-50 w-[9.375rem]"+ sizeClasses="w-[9.375rem]"className="z-50"aria-labelledby={labelId}/>diff --git a/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx b/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsxindex c453e66f4f..efbb77ad79 100644--- a/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx+++ b/client/src/components/Nav/SettingsTabs/Chat/ForkSettings.tsx@@ -45,7 +45,7 @@ export const ForkSettings = () => {value={forkSetting}onChange={setForkSetting}options={forkOptions}- sizeClasses="z-[50] w-[min(12.5rem,90vw)]"+ sizeClasses="w-[min(12.5rem,90vw)]"testId="fork-setting-dropdown"className="z-[50]"aria-labelledby="fork-change-default-label"diff --git a/client/src/components/Nav/SettingsTabs/General/ClockFormatSelector.tsx b/client/src/components/Nav/SettingsTabs/General/ClockFormatSelector.tsxindex 1c49d7f093..3a21eeede9 100644--- a/client/src/components/Nav/SettingsTabs/General/ClockFormatSelector.tsx+++ b/client/src/components/Nav/SettingsTabs/General/ClockFormatSelector.tsx@@ -24,7 +24,7 @@ export default function ClockFormatSelector() {options={options}onChange={(value) => setClockFormat(value as ClockFormatPreference)}testId="clock-format-selector"- sizeClasses="z-50 w-[150px]"+ sizeClasses="w-[150px]"className="z-50"aria-labelledby={labelId}/>diff --git a/client/src/components/Nav/SettingsTabs/General/WeekStartSelector.tsx b/client/src/components/Nav/SettingsTabs/General/WeekStartSelector.tsxindex 4cc3be97f2..c603e99796 100644--- a/client/src/components/Nav/SettingsTabs/General/WeekStartSelector.tsx+++ b/client/src/components/Nav/SettingsTabs/General/WeekStartSelector.tsx@@ -24,7 +24,7 @@ export default function WeekStartSelector() {options={options}onChange={(value) => setWeekStart(value as WeekStartPreference)}testId="week-start-selector"- sizeClasses="z-50 w-[150px]"+ sizeClasses="w-[150px]"className="z-50"aria-labelledby={labelId}/>diff --git a/client/src/components/Nav/SettingsTabs/Integrations/LangfuseConnection.tsx b/client/src/components/Nav/SettingsTabs/Integrations/LangfuseConnection.tsxindex bd69d9978a..70607b9b58 100644--- a/client/src/components/Nav/SettingsTabs/Integrations/LangfuseConnection.tsx+++ b/client/src/components/Nav/SettingsTabs/Integrations/LangfuseConnection.tsx@@ -500,7 +500,7 @@ export default function LangfuseConnection() {disabled={destinations.length === 0 || busy}className="w-full"triggerClassName="w-full"- sizeClasses="z-50 w-[var(--popover-anchor-width)]"+ sameWidthtestId="langfuse-destination"aria-labelledby="langfuse-destination-label"/>diff --git a/client/src/components/Nav/SettingsTabs/Speech/STT/EngineSTTDropdown.tsx b/client/src/components/Nav/SettingsTabs/Speech/STT/EngineSTTDropdown.tsxindex 1cb1d4d7b3..6cf6b8860e 100644--- a/client/src/components/Nav/SettingsTabs/Speech/STT/EngineSTTDropdown.tsx+++ b/client/src/components/Nav/SettingsTabs/Speech/STT/EngineSTTDropdown.tsx@@ -33,7 +33,7 @@ const EngineSTTDropdown: React.FC<EngineSTTDropdownProps> = ({ external }) => {value={engineSTT}onChange={handleSelect}options={endpointOptions}- sizeClasses="z-50 w-[min(11.25rem,90vw)]"+ sizeClasses="w-[min(11.25rem,90vw)]"testId="EngineSTTDropdown"className="z-50"aria-labelledby={labelId}diff --git a/client/src/components/Nav/SettingsTabs/Speech/STT/LanguageSTTDropdown.tsx b/client/src/components/Nav/SettingsTabs/Speech/STT/LanguageSTTDropdown.tsxindex 45d4ff1b2a..cefcf17f72 100644--- a/client/src/components/Nav/SettingsTabs/Speech/STT/LanguageSTTDropdown.tsx+++ b/client/src/components/Nav/SettingsTabs/Speech/STT/LanguageSTTDropdown.tsx@@ -105,7 +105,6 @@ export default function LanguageSTTDropdown() {onChange={handleSelect}options={languageOptions}testId="LanguageSTTDropdown"- sizeClasses="z-50"className="z-50"aria-labelledby={labelId}disabled={!speechToText}diff --git a/client/src/components/Nav/SettingsTabs/Speech/TTS/EngineTTSDropdown.tsx b/client/src/components/Nav/SettingsTabs/Speech/TTS/EngineTTSDropdown.tsxindex 43dcff0189..122e1c0f70 100644--- a/client/src/components/Nav/SettingsTabs/Speech/TTS/EngineTTSDropdown.tsx+++ b/client/src/components/Nav/SettingsTabs/Speech/TTS/EngineTTSDropdown.tsx@@ -33,7 +33,7 @@ const EngineTTSDropdown: React.FC<EngineTTSDropdownProps> = ({ external }) => {value={engineTTS}onChange={handleSelect}options={endpointOptions}- sizeClasses="z-50 w-[min(11.25rem,90vw)]"+ sizeClasses="w-[min(11.25rem,90vw)]"testId="EngineTTSDropdown"className="z-50"aria-labelledby={labelId}diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.tsindex 0831db2f31..0aeebb6b52 100644--- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts+++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts@@ -263,6 +263,32 @@ test.describe('popovers inside a modal dialog', () => {* screen is what shows the dialog stayed open. */await expect(page.getByTestId('default-stateful-workspace')).toBeVisible();});++ /** The stateful workspace Dropdown asks for an 18rem list through `minWidth`, the same prop+ * `DropdownPopup` takes, and gets it wherever the viewport leaves that much room. */+ test('the Settings workspace list takes its minimum width @scenario:dropdown-min-width', async ({+ page,+ }) => {+ await offerStatefulSessions(page);+ await useTheme(page);+ await openWorkspaceDropdown(page);++ const listbox = page.getByRole('listbox');+ /** The list zooms in from 0.95, so its box is only its real size once it settles. */+ await expect(listbox).toHaveAttribute('data-enter');+ await expect+ .poll(() => listbox.evaluate((element) => getComputedStyle(element).scale))+ .toMatch(/^(1|none)$/);+ const { width, viewport } = await listbox.evaluate((element) => ({+ width: element.getBoundingClientRect().width,+ viewport: window.innerWidth,+ }));+ const rem = await page.evaluate(() =>+ parseFloat(getComputedStyle(document.documentElement).fontSize),+ );+ expect(width).toBeGreaterThanOrEqual(Math.min(18 * rem, viewport - rem) - 0.5);+ expect(width).toBeLessThanOrEqual(viewport);+ });});/** Sets both list roles apart from their defaults, so a list still drawing a fixed size shows. */diff --git a/packages/client/src/components/Dropdown.spec.tsx b/packages/client/src/components/Dropdown.spec.tsxindex ad967cb45e..fea19ca393 100644--- a/packages/client/src/components/Dropdown.spec.tsx+++ b/packages/client/src/components/Dropdown.spec.tsx@@ -1,4 +1,5 @@-import { render, screen } from '@testing-library/react';+import React from 'react';+import { act, fireEvent, render, screen } from '@testing-library/react';import Dropdown from './Dropdown';jest.mock('react-i18next', () => ({@@ -149,3 +150,33 @@ describe('Dropdown icon-only trigger', () => {);});});++describe('Dropdown list positioning', () => {+ const openList = async (props: Partial<React.ComponentProps<typeof Dropdown>>) => {+ render(+ <Dropdown+ value="a"+ onChange={jest.fn()}+ ariaLabel="Positioning"+ options={[{ value: 'a', label: 'Alpha' }]}+ {...props}+ />,+ );+ await act(async () => {+ fireEvent.click(screen.getByRole('combobox', { name: /Positioning/ }));+ });+ return screen.findByRole('listbox');+ };++ it('caps a minimum width to the space the list has, as DropdownPopup does', async () => {+ const listbox = await openList({ minWidth: '12rem' });+ expect(listbox.style.minWidth).toBe(+ 'min(12rem, calc(100vw - 1rem), var(--popover-available-width, 100vw))',+ );+ });++ it('leaves the minimum width to the stylesheet when none is given', async () => {+ const listbox = await openList({});+ expect(listbox.style.minWidth).toBe('');+ });+});diff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsxindex 0f8d4b26c7..4f751b072b 100644--- a/packages/client/src/components/Dropdown.tsx+++ b/packages/client/src/components/Dropdown.tsx@@ -52,6 +52,12 @@ interface DropdownProps {searchEmptyText?: string;/** Shown in the secondary tone while no option is chosen. */placeholder?: string;+ /** Draws the list exactly as wide as the trigger, as `DropdownPopup` does. */+ sameWidth?: boolean;+ /** Preferred CSS minimum width for the list, capped to the space available to it. */+ minWidth?: string;+ /** Space between the trigger and the list, in pixels. */+ gutter?: number;}const shapeClasses: Record<DropdownShape, string> = {@@ -94,6 +100,9 @@ const Dropdown: React.FC<DropdownProps> = ({searchPlaceholder,searchEmptyText,placeholder,+ sameWidth,+ minWidth,+ gutter,}) => {const valueId = `${useId()}value`;const inDialog = useDialogDepth() > 0;@@ -245,7 +254,15 @@ const Dropdown: React.FC<DropdownProps> = ({store={selectProps}/* Inside a dialog the list layers over it; elsewhere `z-40` applies. Pointerevents are already re-enabled by the class below. */- style={{ zIndex: inDialog ? popoverZIndex : undefined }}+ style={{+ zIndex: inDialog ? popoverZIndex : undefined,+ minWidth:+ minWidth == null+ ? undefined+ : `min(${minWidth}, calc(100vw - 1rem), var(--popover-available-width, 100vw))`,+ }}+ sameWidth={sameWidth}+ gutter={gutter}data-variant={variant}wrapperProps={variant === 'field' ? { className: 'popover-field-wrapper' } : undefined}className={cn(