[AAASM-3557] 🐛 (docs): Make feedback widget always visible + fix version-banner JS#169
[AAASM-3557] 🐛 (docs): Make feedback widget always visible + fix version-banner JS#169Chisanan232 wants to merge 3 commits into
Conversation
The 'Was this page helpful?' widget (AAASM-3555) was only revealed and wired by mkdocs-material's __md_analytics(), which runs only after analytics consent is granted. With opt-in consent (off by default) the widget stayed hidden for all ordinary visitors. Add a document$-driven script in the theme override that always reveals the widget and wires the 👍/👎 handlers (thank-you note + issue link), without calling gtag — Material's own handler still sends the GA feedback event only when consent is granted, preserving the GDPR posture and avoiding double-counting. Refs AAASM-3557. Fixes AAASM-3555 regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Material's generated outdated-banner reveal script calls
new URL("{{ base_url }}") with no base argument; base_url is a bare
relative value like "." or "..", so new URL("..") throws
'TypeError: Failed to construct URL: Invalid URL' on every page load.
Override partials/javascripts/outdated.html to pass location as the base
(new URL(base_url, location)) instead of forking the installed material
package. Behaviour is otherwise identical.
Refs AAASM-3557.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The version-banner script built versionsUrl by popping only the page's last path segment, so on deep pages it requested /<base>/<version>/versions.json (404) instead of the deploy-root /<base>/versions.json (200). Resolve the URL from the rendered base_url (the deploy root, correct at any page depth) and read ../versions.json relative to it, so the fetch always hits the deploy-root versions.json. Refs AAASM-3557. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude Code — review result ✅ CI green — both checks pass (documentation build, CodeQL); Scope vs AAASM-3557 — all three parts covered, no package fork, no new dependency:
Verified (bundled Chromium, served local strict build, deep page
Sound side-effect: this also makes python's GA (AAASM-3552) actually reachable, since the same opt-in cookie previously gated everything. GDPR posture preserved. Ready for approval + merge. (Post-merge: re-verify on the live versioned |
|
Closing unmerged — superseded by AAASM-3558. Per owner decision (Claude Code review): the python feedback widget's visibility issue is part of a deeper problem — on the live site GA never loads at all for a normal visitor ( Rather than land this widget-only decouple, python's analytics is being reworked comprehensively under AAASM-3558 to match the other four sites (self-managed gtag + Consent Mode v2). That rework folds in everything this PR did and more:
Closing this PR; the carried-over fixes will land via AAASM-3558. Thanks for the work here — it directly informed the rework. |
Description
The "Was this page helpful?" feedback widget (added in AAASM-3555, PR #168) is never visible to ordinary visitors on the published site, plus two secondary JS defects on every page. All three are fixed here, all in the mkdocs-material theme override (
docs/_overrides) — no fork of the installed package, no new dependency.(1) Feedback coupled to analytics consent (primary). mkdocs-material reveals
form.md-feedbackand wires the 👍/👎 handlers only inside its generated__md_analytics(), which runs only after analytics consent is granted. Our consent is opt-in (analytics.checked: false), so__md_analytics()never runs for normal visitors and the widget stayshiddenforever. Fix: adocument$-driven script inmain.htmlthat always reveals the widget and wires our own handlers (thank-you note + pre-filled GitHub issue link), but deliberately does not call gtag — Material's own handler still sends the GAfeedbackevent only when consent is granted. This keeps the GA event consent-gated (GDPR posture preserved) and avoids double-counting.(2)
TypeError: Failed to construct 'URL': Invalid URLon every page. Material'spartials/javascripts/outdated.htmlcallsnew URL("{{ base_url }}")with no base;base_urlis a bare relative value (./..), so it throws on every load. Fixed by overriding that partial to passlocationas the base.(3)
versions.json404 on deep pages. The version-banner script inmain.htmlbuiltversionsUrlby popping only the page's last path segment, requesting/<base>/<version>/versions.json(404) on deep pages. Fixed to resolve from the renderedbase_url(deploy root at any depth) →../versions.json(deploy-root, 200).Type of Change
Breaking Changes
Related Issues
Testing
Local clean build (
uv sync --group docs+uv run mkdocs build --strict) then served and driven with bundled chromium (playwright):Browser verification results:
form.hidden === false, 2 submit buttons present, on a normal page load.feedbackevents pushed todataLayer.href,target=_blank); still 0 events.__consent={"analytics":true}) + reload — click sends exactly 1feedbackevent (no double-count; confirmed by countingdataLayerfeedback pushes).Failed to construct 'URL'error in the console on root, mid, and deep pages (only expectedversions.json404 in the non-versioned local build, which is what fix (3) addresses for the real mike deploy).mkdocs build --strictis clean.GDPR posture preserved: the GA
feedbackevent still fires only with analytics consent; our handler never calls gtag. No new dependency.Checklist
🤖 Generated with Claude Code