diff --git a/client/src/components/Nav/Settings/Dialog.tsx b/client/src/components/Nav/Settings/Dialog.tsx
index 7437da1c1b..6c12c1b545 100644
--- a/client/src/components/Nav/Settings/Dialog.tsx
+++ b/client/src/components/Nav/Settings/Dialog.tsx
@@ -2,7 +2,7 @@ import { useState } from 'react';
import * as Tabs from '@radix-ui/react-tabs';
import { X, ChevronLeft } from 'lucide-react';
import { SettingsTabValues } from 'librechat-data-provider';
-import { Button, useMediaQuery, DIALOG_SCRIM_CLASS } from '@librechat/client';
+import { Button, DialogLayer, useMediaQuery, DIALOG_SCRIM_CLASS } from '@librechat/client';
import { Dialog, DialogPanel, DialogTitle, Transition, TransitionChild } from '@headlessui/react';
import type { TDialogProps } from '~/common';
import type { SettingsTab } from './types';
@@ -101,38 +101,42 @@ export default function SettingsDialog({ open, onOpenChange }: TDialogProps) {
- setActiveTab(v as SettingsTab)}
- orientation="vertical"
- className="flex flex-1 flex-col gap-4 overflow-hidden p-5 md:flex-row md:gap-6"
- >
- {showSidebar && (
-
- )}
- {showContent && (
-
- {searching ? (
-
- ) : (
-
+ {/* A Headless UI panel, so it counts itself as a dialog level for the popovers its
+ settings open (Select lists, menus, tooltips) to layer above it. */}
+
+ setActiveTab(v as SettingsTab)}
+ orientation="vertical"
+ className="flex flex-1 flex-col gap-4 overflow-hidden p-5 md:flex-row md:gap-6"
+ >
+ {showSidebar && (
+
+ )}
+ {showContent && (
+
+ {searching ? (
-
- )}
-
- )}
-
+ ) : (
+
+
+
+ )}
+
+ )}
+
+
diff --git a/e2e/specs/mock/scenarios/nested-popovers.spec.ts b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
index 88c35eecf8..f7ce0c7f53 100644
--- a/e2e/specs/mock/scenarios/nested-popovers.spec.ts
+++ b/e2e/specs/mock/scenarios/nested-popovers.spec.ts
@@ -37,8 +37,15 @@ async function useTheme(page: Page, definition?: { name: string }) {
}, definition ?? null);
}
-/** The stateful workspace Select only renders when the agents endpoint offers stateful sessions. */
+/** The stateful workspace Select only renders when the agents endpoint offers stateful sessions;
+ * a pick's save is answered here so it stands without a configured code environment. */
async function offerStatefulSessions(page: Page) {
+ await page.route('**/api/user/preferences', async (route) => {
+ if (route.request().method() === 'GET') {
+ return route.continue();
+ }
+ await route.fulfill({ json: { preferences: route.request().postDataJSON() } });
+ });
await page.route('**/api/endpoints', async (route) => {
const response = await route.fetch();
const endpoints = await response.json();
@@ -49,8 +56,7 @@ async function offerStatefulSessions(page: Page) {
});
}
-/** Opens the Settings Select's list. Only its geometry is read, which does not depend on how the
- * list layers against the Settings dialog. */
+/** Opens the stateful workspace Select's list in the Settings dialog. */
async function openWorkspaceSelect(page: Page) {
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
/** Mobile keeps the account menu in the drawer. */
@@ -138,6 +144,43 @@ test.describe('popovers inside a modal dialog', () => {
await openWorkspaceSelect(page);
await expectIndicator(page, '20px');
});
+
+ /** The Settings dialog is a Headless UI panel, not an OGDialog; before it declared a dialog
+ * level its Select lists painted behind it (berry-13/LibreChat#249). Hit testing alone cannot
+ * show that: the open list sets `pointer-events: none` on the body, so the panel is skipped and
+ * a click falls through to a list nobody can see. The probe turns pointer events back on
+ * everywhere so `elementFromPoint` reports what is painted on top. */
+ test('a Select in the Settings dialog opens on top of it and takes a pick @scenario:settings-select-opens-on-top', async ({
+ page,
+ }) => {
+ await offerStatefulSessions(page);
+ await useTheme(page);
+ await openWorkspaceSelect(page);
+
+ const option = page.getByRole('option', { name: 'Conversation workspace' });
+ const box = await option.boundingBox();
+ expect(box).not.toBeNull();
+ const x = (box?.x ?? 0) + (box?.width ?? 0) / 2;
+ const y = (box?.y ?? 0) + (box?.height ?? 0) / 2;
+ const painted = await page.evaluate(
+ ([px, py]) => {
+ const probe = document.createElement('style');
+ probe.textContent = '* { pointer-events: auto !important; }';
+ document.head.append(probe);
+ const top = document.elementFromPoint(px, py);
+ probe.remove();
+ return top?.closest('[role="listbox"]') != null;
+ },
+ [x, y],
+ );
+ expect(painted).toBe(true);
+
+ await page.mouse.click(x, y);
+ await expect(page.getByRole('listbox')).toBeHidden();
+ await expect(page.getByTestId('default-stateful-workspace')).toHaveText(
+ 'Conversation workspace',
+ );
+ });
});
/** Sets both list roles apart from their defaults, so a list still drawing a fixed size shows. */
diff --git a/packages/client/src/components/OriginalDialog.tsx b/packages/client/src/components/OriginalDialog.tsx
index 9c86624814..e8fae0fb23 100644
--- a/packages/client/src/components/OriginalDialog.tsx
+++ b/packages/client/src/components/OriginalDialog.tsx
@@ -12,6 +12,15 @@ const DialogDepthContext = React.createContext(0);
/** Current OGDialog nesting depth (0 when rendered outside any dialog). */
export const useDialogDepth = (): number => React.useContext(DialogDepthContext);
+/**
+ * Counts a dialog that is not an OGDialog, such as a Headless UI panel, as one dialog level, so
+ * the popovers portaled out of it layer above it the way they do inside an OGDialog.
+ */
+export const DialogLayer = ({ children }: { children: React.ReactNode }): React.JSX.Element => {
+ const depth = React.useContext(DialogDepthContext);
+ return {children};
+};
+
/**
* z-index for a portaled popover so it renders above the dialog it lives in.
* Outside any dialog (depth 0) it falls back to a low default (50).
diff --git a/packages/client/src/components/__tests__/popoverLayering.spec.tsx b/packages/client/src/components/__tests__/popoverLayering.spec.tsx
index 1648e96bd8..b5f291cd92 100644
--- a/packages/client/src/components/__tests__/popoverLayering.spec.tsx
+++ b/packages/client/src/components/__tests__/popoverLayering.spec.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { HoverCard, HoverCardContent, HoverCardPortal, HoverCardTrigger } from '../HoverCard';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../Select';
-import { OGDialog, OGDialogContent } from '../OriginalDialog';
+import { DialogLayer, OGDialog, OGDialogContent } from '../OriginalDialog';
/**
* A portaled popover lands beside the dialog in the DOM, not inside it, so its
@@ -61,6 +61,20 @@ describe('portaled popovers inside a dialog', () => {
expect(listbox).toHaveClass('pointer-events-auto');
});
+ /** The Settings dialog is a Headless UI panel at z-50, not an OGDialog, so it declares its own
+ * dialog level (berry-13/LibreChat#249). */
+ it('opens a select above a non-OGDialog panel that declares a dialog layer', () => {
+ render(
+
+
+ ,
+ );
+
+ const listbox = screen.getByRole('listbox');
+ expect(zIndexOf(listbox)).toBeGreaterThan(50);
+ expect(listbox).toHaveClass('pointer-events-auto');
+ });
+
it('opens a hover card above the dialog content it belongs to', () => {
render(