Repository navigation
Conversation
The factsheets table calls renderDetailPanel for every row on each render, and DrugInfoCard was called there as a plain function, so every row's card was computed each time, collapsed or not. Render it as an element instead, so only expanded rows build one. Memoise DrugInfoCard so table re-renders (each filter keystroke, for example) no longer re-render an open card. react-apexcharts compares its options deeply, and the inline tooltip functions never compare equal, so each re-render redrew both charts from scratch. Turn off the charts' grow-in animation, which kept the browser drawing frames for about two seconds after a row was expanded. Refs #289 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #289
What this changes
renderDetailPanelfor every row on the page on every render, expanded or not, and only mounts the result when the row is open.Factsheets.tsxcalledDrugInfoCard({ drugData })as a plain function there, so every row's card was computed on each table render. It now returns<DrugInfoCard drugData={row.original} />.DrugInfoCardis wrapped inmemo. Without it, every table render (each keystroke in a column filter, for example) re-rendered the open card.react-apexchartsdeep-compares itsoptionsprop, and the inlinetooltip.customfunctions never compare equal, so both charts were redrawn from scratch each time.Measurements
Production build, headless Chrome 148 via puppeteer, 1600×1000, expanding the LSD row. Baseline is
uatat 7724008.The cost of the expansion itself didn't change: about 0.3 s of JS, or about 1.8 s with 4× CPU throttling (mostly drawing the two charts plus the MUI mount).
Not reproduced
The 30–60 s busy renderer described in #289 did not reproduce. I tried headless Chrome, headful Chrome under WSLg, the live tripsit.io, several heavy drugs (LSD, pregabalin, diphenhydramine, ketamine), widths from 800 to 1920 px, DPR 1–2, 4× CPU throttling, 100 rows per page, expand-all, and 16 expand/collapse cycles. In each case the page went fully idle once the expansion settled (no commits, paints or running animations), and heap, window listeners and ApexCharts instances stayed flat across cycles. So this PR removes the measurable waste around an expansion, but I can't confirm it removes the original symptom. That's why it says "Refs" rather than "Closes". It would be worth re-checking in a desktop Chrome with a GPU before closing #289.
Tests
FactsheetsDetailPanel.test.tsx: with two collapsed rows, the card component is never called. After expanding one, it is called only for that row. Fails onuat(8 calls before any expansion).DrugInfo.test.tsx: an open card draws its two charts once, with animations disabled, and re-rendering it with the same drug does not render the charts again. Fails onuatand fails separately if only thememois removed.npx eslint .,npm test -- --coverage(110 tests, branch coverage 90.28%),npx next buildall pass.git merge-treeshows no conflict with #308, which also editsDrugInfo.tsx.🤖 Generated with Claude Code