Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/lab/[slug]/experiment/[experimentId]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ExperimentLayout from '@/components/experiment/ExperimentLayout';
import ContentBlock from '@/components/experiment/ContentBlock';
import PrintSettingsWrapper from '@/components/experiment/PrintSettingsWrapper';
import styles from '@/components/experiment/Experiment.module.css';
import ExportButtonClient from "@/components/experiment/ExportButtonClient";

/**
* Validates and retrieves parameters (slug, experimentId).
Expand All @@ -28,9 +29,9 @@ export default async function ExperimentPage({ params }) {

// Standardize ID to include labSlug to avoid collisions
const fullExperimentId = `${slug}/${experimentId}`;

return (
<ExperimentLayout experiment={experiment} fullExperimentId={fullExperimentId}>
<ExportButtonClient experiment={experiment} />
{SECTION_ORDER.map((sectionKey) => {
Comment on lines 33 to 35
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Expose registerChart to the components that actually create charts.

Mounting the export widget here is not enough for plot capture. components/experiment/PlotPanel.js still owns a local chartRef and never sees the hook's registerChart, so the registry stays empty and PDFs won't include generated plots.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/lab/`[slug]/experiment/[experimentId]/page.js around lines 33 - 35,
ExportButtonClient's chart registry (registerChart) isn't reachable by
PlotPanel, so move or expose the hook where PlotPanel can call it: lift the
export hook that provides registerChart up into the ExperimentLayout (or a
parent that wraps children) and pass registerChart down to children that create
charts (e.g., pass as a prop into PlotPanel or provide it via React context), or
alternatively change ExportButtonClient to accept a registerChart prop from its
parent; update PlotPanel to call registerChart with its local chartRef so the
registry is populated for PDF export.

const section = experiment.sections[sectionKey];
// Safety check: if section data is missing for some reason
Expand Down
11 changes: 11 additions & 0 deletions components/experiment/ExportButtonClient.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client";

import { useLabReportExport } from "@/lib/useLabReportExport";
import { ExportPDFWidget } from "@/components/experiment/ExportPDFButton";

export default function ExportButtonClient({ experiment }) {
const exportProps = useLabReportExport(experiment);
return (
<ExportPDFWidget {...exportProps} experimentTitle={experiment.title} />
);
}
Loading