Skip to content

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

🪚 fix: Restore Measured Width to Virtualized Model Lists (#16252)

lia-by-librechat[bot]9994b2cc10bf
diff --git a/client/src/components/Chat/Menus/Endpoints/components/VirtualizedModelList.tsx b/client/src/components/Chat/Menus/Endpoints/components/VirtualizedModelList.tsx
index 91d0daf44f..552dc31981 100644
--- a/client/src/components/Chat/Menus/Endpoints/components/VirtualizedModelList.tsx
+++ b/client/src/components/Chat/Menus/Endpoints/components/VirtualizedModelList.tsx
@@ -170,7 +170,6 @@ export default function VirtualizedModelList({
overscanRowCount={OVERSCAN}
rowRenderer={rowRenderer}
className="outline-none!"
- style={{ width: '100%' }}
/**
* `List` spreads its props onto the underlying `Grid`, whose defaults are
* `role="grid"`, `containerRole="row"` and `tabIndex={0}`. Left alone, that puts a
diff --git a/client/src/components/Chat/Menus/Endpoints/components/__tests__/VirtualizedModelList.layout.test.tsx b/client/src/components/Chat/Menus/Endpoints/components/__tests__/VirtualizedModelList.layout.test.tsx
new file mode 100644
index 0000000000..b85f437b7c
--- /dev/null
+++ b/client/src/components/Chat/Menus/Endpoints/components/__tests__/VirtualizedModelList.layout.test.tsx
@@ -0,0 +1,53 @@
+import { render } from '@testing-library/react';
+import type { Endpoint } from '~/common';
+import VirtualizedModelList from '../VirtualizedModelList';
+
+jest.mock('@ariakit/react', () => ({
+ useComboboxContext: () => null,
+}));
+
+jest.mock('../EndpointModelItem', () => ({
+ EndpointModelItem: ({ modelId }: { modelId: string }) => (
+ <div role="option" aria-selected="false">
+ {modelId}
+ </div>
+ ),
+}));
+
+const endpoint: Endpoint = {
+ value: 'openrouter',
+ label: 'OpenRouter',
+ hasModels: true,
+ models: [],
+ icon: null,
+};
+
+it('keeps virtualized rows visible when AutoSizer uses a zero-width wrapper', () => {
+ let containerWidth = 300;
+ jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockImplementation(function (
+ this: HTMLElement,
+ ) {
+ return this.hasAttribute('data-endpoint-models') ? containerWidth : 0;
+ });
+
+ const modelIds = Array.from({ length: 150 }, (_, index) => `model-${index}`);
+ const props = {
+ endpoint,
+ modelIds,
+ globalByName: new Map<string, boolean>(),
+ isFavorite: () => false,
+ onToggleFavorite: () => undefined,
+ precedingOptionCount: 0,
+ };
+ const { container, rerender } = render(<VirtualizedModelList {...props} key="all" />);
+ const grid = container.querySelector<HTMLElement>('.ReactVirtualized__Grid');
+
+ expect(grid?.parentElement).toHaveStyle({ width: '0px' });
+ expect(grid).toHaveStyle({ width: '300px' });
+ expect(container.querySelectorAll('[role="option"]').length).toBeGreaterThan(0);
+ expect(container.querySelectorAll('[role="option"]').length).toBeLessThan(modelIds.length);
+
+ containerWidth = 420;
+ rerender(<VirtualizedModelList {...props} key="broad-search" />);
+ expect(container.querySelector('.ReactVirtualized__Grid')).toHaveStyle({ width: '420px' });
+});