Repository navigation
fix: make rapid response work with MathJax v4 - #969
Conversation
edx-platform master loads MathJax 4.1.2. Its asciimath input leaves a MathJax.Hub object on the page whose Queue() throws, and rapid.js called it on every chart render, so the chart never drew and "Open problem now" never sent its request. - Use the MathJax v2 Hub API only when MathJax.version starts with "2.". - On newer versions typeset tooltips with typesetPromise() and leave the x axis labels as raw TeX. - Pass the tooltip DOM node to MathJax instead of the undefined jQuery ".el" property. - Skip the resize re-render until the first responses fetch has loaded. - Bump rapid-response-xblock to 0.12.1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Summary
Supports rapid response panels with MathJax v4 while preserving MathJax v2 support.
- Fixes: MathJax v4 rendering failures by using
typesetPromise()and restrictingHubcalls to v2. - Fixes: premature chart rendering during window resize before the first responses fetch completes.
- Changes: the package version to 0.12.1 for the rapid response XBlock.
Dependencies changed: src/rapid_response_xblock/pyproject.toml
Details for reviewers
Risks
- Answer text using
$...$remains unrendered on MathJax v4 because$delimiters are configured only for v2.
Core files: src/rapid_response_xblock/rapid_response_xblock/static/js/src_js/rapid.js
More changes
- Changes: MathJax v4 chart x-axis labels to remain as raw TeX because HTML cannot render inside the chart SVG. (
rapid.js)
Unchanged
- MathJax v2 continues using its
HubAPI for chart and tooltip typesetting.
Summary of effe9cf · React 👍 or 👎 on my comments to tune what I raise · Commands · Review config
There was a problem hiding this comment.
🟡 Changes recommended
Tooltip handlers replace or clear typeset content without calling typesetClear(), causing MathJax to retain orphaned expressions and detached DOM across repeated hovers.
1 open issue
What changed in this PR
Updates the rapid response XBlock for MathJax v4, addressing chart-rendering errors that prevent the panel from loading and problems from opening.
Changes:
- Restricts legacy MathJax calls to v2 and uses
typesetPromise()for newer-version tooltips, leaving chart-axis math unrendered. - Prevents resize-triggered rendering before response data loads.
- Bumps
rapid-response-xblockto 0.12.1 and updates the lockfile.
| File | Description |
|---|---|
uv.lock |
Synchronizes the plugin version to 0.12.1. |
src/rapid_response_xblock/rapid_response_xblock/static/js/src_js/rapid.js |
Adds version-aware MathJax handling, corrects the tooltip DOM reference, and guards early resize rendering. |
src/rapid_response_xblock/pyproject.toml |
Bumps the plugin release version to 0.12.1. |
Review effort: Balanced
Address review feedback on #969: call typesetClear() before the shared tooltip's content is replaced so MathJax doesn't retain orphaned expressions, serialize that with pending typesets, and stop passing the bare MathJax global into the IIFE so the file loads when MathJax isn't defined yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mark chart SVGs tex2jax_ignore on MathJax v3+ so the platform's page-wide typeset doesn't blank the raw TeX tick labels, match a literal \( / \) instead of any parenthesis when detecting math, read window.MathJax once in setTooltipContent, and trim the mathJaxHub comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Underscore's _.includes on a string compares single characters, so
_.includes(text, "\\(") never matched and \(...\) answers stopped
typesetting on MathJax v4 and splitting in chart labels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
asadali145
left a comment
There was a problem hiding this comment.
Thanks for the quick fixes! Re-tested on local Tutor (edx-platform master, MathJax 4.1.2): \(x^2\) tooltips typeset and clear again, axis labels stay raw TeX after resize and on a cold load, and open/close works with no console errors. The MathJax v2 path is untested on my side.
) * chore(deps): hold verawood-only pins that Renovate keeps proposing Renovate opened bumps for three overrides in build_manifest.yaml that are held on purpose, with nothing in its config to say so: - rapid-response-xblock on the verawood mitx cells stays on 0.12.0, because Verawood loads MathJax 2 and 0.12.1 onward is built for MathJax 4 (#426, mitodl/open-edx-plugins#969). #414 proposed 0.12.2. - openedx-forum on the verawood cells exists only to reach the 0.4.7 Typesense fix. 0.5.0 gates the forum HTTP API behind FORUM_ENABLE_HTTP_API and 0.6.0 adds a migration that no edx-platform branch pins yet (master is on 0.5.0). #371 proposed 0.6.1. - edx-django-utils 8.2.0 onward requires Python 3.12, and the ulmo xpro cell runs 3.11. Verawood moves to 8.2.1 separately, which leaves ulmo as the only 8.1.0 match. Ulmo retires when xPRO moves to Verawood in production on 2026-12-16; the rule goes with it. The rapid-response and edx-django-utils rules match on the current version because the same package is pinned in cells that should keep updating. Claude-Session: https://claude.ai/code/session_01FGZebFCSK2StX76C2fxunU * fix: scope the openedx-forum hold to 0.4.x pins and correct the edx-django-utils note Without matchCurrentVersion, the openedx-forum rule would also cap a cell that already pins 0.5 or later below 0.5. The edx-django-utils description claimed the verawood cells are not matched, which only holds once #457 bumps them to 8.2.1. Claude-Session: https://claude.ai/code/session_01FGZebFCSK2StX76C2fxunU

What are the relevant tickets?
N/A. Upstream context: openedx/openedx-platform#33555 (MathJax v4 upgrade)
Description (What does it do?)
On edx-platform master the rapid response panel shows no graph and "Open problem now" spins forever. Master now loads MathJax 4.1.2, whose asciimath input leaves a
MathJax.Hubobject on the page with aQueue()that throws, andrapid.jscalled it on every chart render.HubAPI only whenMathJax.versionstarts with2..typesetPromise()and skip typesetting the chart's x axis labels.rapid-response-xblockto 0.12.1.Implementation details
TypeError: Cannot read properties of undefined (reading 'Push')atObject.Queueinmathjax@4.1.2/input/asciimath.js, called fromrenderMathHJax. On page load it fired after the controls were drawn, so the button showed without a graph. On click it fired before thetoggle_block_open_statusrequest was sent, so the "Opening problem" spinner never cleared.MathJax.Hub, becauseHubexists on v4 too.$tooltipContainer.el, which isundefinedon a jQuery object. It now passes the DOM node, so v2 typesets the tooltip instead of the whole page.$...$also stays raw on v4: theHub.Configcall that added$as a delimiter is v2-only, and the platform's v4 config only declares\(...\)and[mathjaxinline].Cannot read properties of undefined (reading 'None')from the run dropdown, because the state had nototal_countsyet.How can this be tested?
Tested in a local Tutor dev environment on an edx-platform branch 10 commits ahead of upstream master, which loads
mathjax@4.1.2:rapid_response_xblockin LMS and CMS.toggle_block_open_statusrequest in the LMS log.toggle_block_open_statusreturning 200.Option (a) \(x^2\),$y_1$andOption (a) plain): the tooltip renders\(x^2\)and clears on mouseout with no math left in MathJax's document after repeated hovers, the\(x^2\)label splits onto two lines, the plain label doesn't, and a page-wide typeset leaves the chart's labels as raw TeX.Not tested:
rapid.js, and the integration tests do not run it.Screenshots
Rapid response panel as staff on edx-platform master (MathJax 4.1.2).
main)Additional Context
rapid-response-xblockto 0.12.1. Whichever merges second needs 0.12.2.🤖 Generated with Claude Code