#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Fix crash in Processor when loading tool settings with tooltips (#7015)
James Brunton4d4e99456283
diff --git a/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.test.tsx b/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.test.tsxnew file mode 100644index 0000000000..698fb0028a--- /dev/null+++ b/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.test.tsx@@ -0,0 +1,52 @@+import { describe, expect, it, vi } from "vitest";+import { render, screen } from "@testing-library/react";+import { MantineProvider } from "@mantine/core";+import { Tooltip } from "@app/components/shared/Tooltip";+import type { ToolRegistry } from "@app/data/toolsTaxonomy";+import type { WorkingToolStep } from "@app/hooks/tools/shared/toolAutomation";+import { PipelineStepSettings } from "@portal/components/pipelines/PipelineStepSettings";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string, fallback?: string) => fallback ?? key,+ }),+}));++// A stand-in tool-settings UI that uses the shared editor Tooltip. The Tooltip+// pulls in the Preferences + Sidebar contexts, which the portal does not mount+// app-wide — so this reproduces the "usePreferences must be used within a+// PreferencesProvider" crash unless PipelineStepSettings supplies them.+function TooltipSettings() {+ return (+ <Tooltip content="help">+ <button type="button">field</button>+ </Tooltip>+ );+}++const step = {+ support: "editable",+ toolId: "compress",+ params: {},+} as unknown as WorkingToolStep;++const registry = {+ compress: { automationSettings: TooltipSettings },+} as unknown as Partial<ToolRegistry>;++describe("PipelineStepSettings", () => {+ it("renders reused editor tool settings (which use the shared Tooltip) without app-wide Preferences/Sidebar providers", () => {+ expect(() =>+ render(+ <MantineProvider>+ <PipelineStepSettings+ step={step}+ registry={registry}+ onChange={() => {}}+ />+ </MantineProvider>,+ ),+ ).not.toThrow();+ expect(screen.getByText("field")).toBeInTheDocument();+ });+});diff --git a/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.tsx b/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.tsxindex fe2ee9dd2a..672383ecd3 100644--- a/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.tsx+++ b/frontend/editor/src/portal/components/pipelines/PipelineStepSettings.tsx@@ -1,6 +1,8 @@import { Suspense } from "react";import { useTranslation } from "react-i18next";import { Banner } from "@app/ui";+import { PreferencesProvider } from "@app/contexts/PreferencesContext";+import { SidebarProvider } from "@app/contexts/SidebarContext";import { type ToolRegistry } from "@app/data/toolsTaxonomy";import { type ErasedToolParams } from "@app/hooks/tools/shared/toolOperationTypes";import { type WorkingToolStep } from "@app/hooks/tools/shared/toolAutomation";@@ -46,14 +48,18 @@ export function PipelineStepSettings({}return (- <Suspense fallback={null}>- <Settings- parameters={step.params}- onParameterChange={(key, value) =>- onChange({ ...step.params, [key]: value })- }- disabled={false}- />- </Suspense>+ <PreferencesProvider>+ <SidebarProvider>+ <Suspense fallback={null}>+ <Settings+ parameters={step.params}+ onParameterChange={(key, value) =>+ onChange({ ...step.params, [key]: value })+ }+ disabled={false}+ />+ </Suspense>+ </SidebarProvider>+ </PreferencesProvider>);}