Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(dropdown): drop the `fixed` positioning strategy nine dropdowns asked for
Elian Doran877b78103bd8
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsxindex 76f00f3868..7b5486ed18 100644--- a/apps/client/src/widgets/dialogs/revisions.tsx+++ b/apps/client/src/widgets/dialogs/revisions.tsx@@ -245,7 +245,6 @@ function RevisionsMenu({ note, onRevisionSaved, onAllDeleted, hasRevisions }: {noSelectButtonStylebuttonProps={{ title: t("revisions.menu_tooltip") }}dropdownContainerClassName="mobile-bottom-menu"- dropdownOptions={{ popperConfig: { strategy: "fixed" } }}><FormListItemicon="bx bx-save"diff --git a/apps/client/src/widgets/layout/Breadcrumb.tsx b/apps/client/src/widgets/layout/Breadcrumb.tsxindex 07a6c94f0a..a288893c1e 100644--- a/apps/client/src/widgets/layout/Breadcrumb.tsx+++ b/apps/client/src/widgets/layout/Breadcrumb.tsx@@ -203,7 +203,7 @@ function BreadcrumbSeparator(props: BreadcrumbSeparatorProps) {buttonClassName="icon-action breadcrumb-separator"hideToggleArrowdropdownContainerClassName="breadcrumb-child-list"- dropdownOptions={{ popperConfig: { strategy: "fixed", placement: "top" } }}+ dropdownOptions={{ popperConfig: { placement: "top" } }}><BreadcrumbSeparatorDropdownContent {...props} /></Dropdown>@@ -255,7 +255,6 @@ function BreadcrumbCollapsed({ items, noteContext }: {buttonClassName="icon-action"dropdownContainerClassName="breadcrumb-child-list"hideToggleArrow- dropdownOptions={{ popperConfig: { strategy: "fixed" } }}>{items.map((notePath) => {const notePathComponents = notePath.split("/");diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsxindex d60770d458..9c2b11102b 100644--- a/apps/client/src/widgets/layout/StatusBar.tsx+++ b/apps/client/src/widgets/layout/StatusBar.tsx@@ -113,7 +113,6 @@ function StatusBarDropdown({ children, icon, text, buttonClassName, dropdownCont}}dropdownOptions={{popperConfig: {- strategy: "fixed",placement: "top"},...dropdownOptionsdiff --git a/apps/client/src/widgets/react/Badge.tsx b/apps/client/src/widgets/react/Badge.tsxindex f432c10182..b33b40b447 100644--- a/apps/client/src/widgets/react/Badge.tsx+++ b/apps/client/src/widgets/react/Badge.tsx@@ -78,7 +78,7 @@ export function BadgeWithDropdown({ text, children, tooltip, className, dropdown...dropdownOptions?.dropdownOptions,popperConfig: {...dropdownOptions?.dropdownOptions?.popperConfig,- placement: "bottom", strategy: "fixed"+ placement: "bottom"}}}>{children}</Dropdown>diff --git a/apps/client/src/widgets/sidebar/SidebarChat.tsx b/apps/client/src/widgets/sidebar/SidebarChat.tsxindex be629a8182..f902ba054e 100644--- a/apps/client/src/widgets/sidebar/SidebarChat.tsx+++ b/apps/client/src/widgets/sidebar/SidebarChat.tsx@@ -315,7 +315,6 @@ export default function SidebarChat() {title={t("sidebar_chat.history")}iconActionhideToggleArrow- dropdownOptions={{ popperConfig: { strategy: "fixed" } }}dropdownRef={historyDropdownRef}onShown={loadRecentChats}>@@ -365,7 +364,6 @@ export default function SidebarChat() {title={t("sidebar_chat.more_actions")}iconActionhideToggleArrow- dropdownOptions={{ popperConfig: { strategy: "fixed" } }}><FormListItemicon="bx bx-save"@@ -407,7 +405,6 @@ export default function SidebarChat() {activeNoteId={activeNoteId ?? undefined}activeNoteTitle={activeNote?.title}onSubmit={handleSubmit}- inSidebar/>)}</div>diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsxindex d9367fd243..218295bd02 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx@@ -83,8 +83,6 @@ interface ChatInputBarProps {onExtendedThinkingChange?: () => void;/** Callback when model changes */onModelChange?: (model: string) => void;- /** Rendered inside the narrow right sidebar — opens the model submenu leftwards so it doesn't overflow. */- inSidebar?: boolean;}export default function ChatInputBar({@@ -95,8 +93,7 @@ export default function ChatInputBar({onWebSearchChange,onNoteToolsChange,onExtendedThinkingChange,- onModelChange,- inSidebar+ onModelChange}: ChatInputBarProps) {// Provider add/edit modal. `modalProvider` undefined = adding; a config = editing.// The bumping token re-keys the modal so it re-initializes its wizard on each open.@@ -436,7 +433,6 @@ export default function ChatInputBar({titlePosition="top"buttonClassName="llm-chat-model-select"className="llm-chat-model-dropdown"- dropdownOptions={inSidebar ? { popperConfig: { strategy: "fixed" } } : undefined}>{chat.modelGroups.map(group => (<Fragment key={group.id}>@@ -475,7 +471,6 @@ export default function ChatInputBar({value={chat.reasoningEffort}onChange={handleReasoningEffortChange}disabled={chat.isStreaming}- inSidebar={inSidebar}/>) : null}</div>diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.spec.tsxindex be568187a0..2b7543dd64 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.spec.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.spec.tsx@@ -7,14 +7,12 @@ vi.mock("../../../services/i18n.js", () => ({t: (key: string, options?: { level?: string }) => (options?.level ? `${key}(${options.level})` : key)}));-// Renders the toggle's face, its tooltip and class, and the menu, without Bootstrap;-// the placement options go on data attributes.+// Renders the toggle's face, its tooltip and class, and the menu, without Bootstrap.vi.mock("../../react/Dropdown.js", () => ({- default: ({ text, title, buttonClassName, children, dropdownOptions }: {+ default: ({ text, title, buttonClassName, children }: {text: ComponentChildren; title?: string; buttonClassName?: string; children: ComponentChildren;- dropdownOptions?: { popperConfig?: { strategy?: string } };}) => (- <div className="dropdown-stub" data-strategy={dropdownOptions?.popperConfig?.strategy ?? "none"}>+ <div className="dropdown-stub"><button className={buttonClassName} title={title}>{text}</button><div className="menu">{children}</div></div>@@ -36,10 +34,10 @@ afterEach(() => {}});-function renderDropdown(model: LlmModelInfo, value: Parameters<typeof ReasoningEffortDropdown>[0]["value"], onChange = vi.fn(), inSidebar = false) {+function renderDropdown(model: LlmModelInfo, value: Parameters<typeof ReasoningEffortDropdown>[0]["value"], onChange = vi.fn()) {host = document.body.appendChild(document.createElement("div"));const target = host;- act(() => render(<ReasoningEffortDropdown model={model} value={value} onChange={onChange} inSidebar={inSidebar} />, target));+ act(() => render(<ReasoningEffortDropdown model={model} value={value} onChange={onChange} />, target));return { host: target, onChange };}@@ -55,21 +53,12 @@ describe("effectiveReasoningEffort", () => {});});-describe("ReasoningEffortDropdown placement", () => {- it("fixes the menu's position in the sidebar", () => {- const stub = renderDropdown(FLASH, undefined, vi.fn(), true).host.querySelector(".dropdown-stub");- expect(stub?.getAttribute("data-strategy")).toBe("fixed");- });-- it("leaves the position alone elsewhere, and lists nothing for a model without levels", () => {+describe("ReasoningEffortDropdown", () => {+ it("lists nothing for a model without levels", () => {const { host: plain } = renderDropdown({ id: "m", name: "M" }, undefined);- const stub = plain.querySelector(".dropdown-stub");- expect(stub?.getAttribute("data-strategy")).toBe("none");expect(plain.querySelectorAll(".menu .dropdown-item")).toHaveLength(0);});-});-describe("ReasoningEffortDropdown", () => {it("lists the model's levels, ticks the one in effect and picks another", () => {const { host, onChange } = renderDropdown(PRO, "medium");diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.tsxindex 5d6dfbcb6d..13e3b3286e 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ReasoningEffortDropdown.tsx@@ -12,13 +12,12 @@ import Icon from "../../react/Icon.js";* `reasoningEfforts`; such a model has no extended thinking switch. It stands* beside the model picker and shares its combobox styling.*/-export default function ReasoningEffortDropdown({ model, value, onChange, disabled, inSidebar }: {+export default function ReasoningEffortDropdown({ model, value, onChange, disabled }: {model: LlmModelInfo;/** The chat's chosen level; undefined means the model's default. */value: LlmReasoningEffort | undefined;onChange: (effort: LlmReasoningEffort) => void;disabled?: boolean;- inSidebar?: boolean;}) {const effective = effectiveReasoningEffort(model, value);const label = t(`llm_chat.reasoning_effort_levels.${effective}`);@@ -34,7 +33,6 @@ export default function ReasoningEffortDropdown({ model, value, onChange, disablbuttonClassName="llm-chat-model-select"className="llm-chat-reasoning-effort"disabled={disabled}- dropdownOptions={inSidebar ? { popperConfig: { strategy: "fixed" } } : undefined}>{(model.reasoningEfforts ?? []).map(level => (<FormListItem key={level} checked={level === effective} onClick={() => onChange(level)}>