fix: keep /web problem statements clear of the problem switcher
What does this PR aim to accomplish?:
Closes #1072 — on the new /web contest problem pages, the fixed problem switcher covers the left edge of the problem statement.
How does this PR accomplish the above?:
On the legacy pages the content sat in a centred container, leaving room on the left for the switcher. In the /web app, the problem view's .jumbotron spans the full width (live DOM: #app > div > .jumbotron > .xmoj-problem-body > .cnt-row), so the switcher sits on top of the statement.
- After the switcher is mounted, its width is measured and stored as
--xmoj-problem-switcher-widthon#app; aResizeObserveron the switcher re-measures it (font loading, media queries, viewport changes) and is disconnected when the route'sAbortControlleraborts #app .jumbotron { margin-left: var(--xmoj-problem-switcher-width, 0px); }(the variable is only set on problem pages) — the width is 0 when the switcher is hidden (e.g. the ≤768px rule in MonochromeUI), so nothing moves thenClearRoute()removes the variable when leaving the page
One custom CSS rule is unavoidable here: Bootstrap has no class for clearing a fixed element of measured width.
Does this PR need a documentation update?:
No
Testing / not yet verified:
node --check XMOJ.user.jspasses; the 12 non-browser tests pass (same as ondev)- The 5 Playwright tests were not run (no matching Chromium installed locally)
- Not yet tested in a browser, so item 11 (all four UI combinations) is not verified — the review checkbox below is left unchecked until a maintainer QA-tests it. The switcher is only created on the
/webproblem pages, so the classic pages should be unaffected
By submitting this pull request, I confirm the following:
- I have read and understood the contributor's guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against. (
devfor XMOJ-Script,masterfor everything else). - I have commented on my proposed changes within the code.
- I have tested my changes.
- I am willing to help maintain this change if there are issues with it later.
- It is compatible with the GNU General Public License v3.0
- I have squashed any insignificant commits. (
git rebase) - I have checked that another pull request for this purpose does not exist.
- I have considered and confirmed that this submission will be valuable to others.
- I accept that this submission may not be used, and the pull request can be closed at the will of the maintainer.
- I give this submission freely and claim no ownership to its content.
- I have verified that my changes work correctly in all four UI combinations:
- the script's monochrome UI on XMOJ's new UI (
/webpages) - the script's monochrome UI on XMOJ's old/classic pages
- the script's classic UI on XMOJ's new UI (
/webpages) - the script's classic UI on XMOJ's old/classic pages
- the script's monochrome UI on XMOJ's new UI (
- I have read the above and my PR is ready for review. Check this box to confirm
🤖 Generated with Claude Code
https://claude.ai/code/session_01JhQLfJB3LWW4vkNXK85xL1
Summary by Sourcery
Keep /web contest problem statements clear of the fixed problem switcher across layout changes.
Bug Fixes:
- Prevent the fixed problem switcher from obscuring the left edge of problem statements on
/webcontest pages.
Enhancements:
- Reserve responsive space for the problem switcher and clean up that layout state when navigating away.
Build:
- Bump the project and userscript version to 4.0.7.
Summary by cubic
Keeps /web contest problem statements clear of the fixed problem switcher that previously covered the left edge of the statement (#1072). Bumps the project and userscript version to 4.0.7.
- Measures the switcher after it mounts and applies its width as a left margin on the full-width problem view (
#app .jumbotron); aResizeObserverre-measures it whenever the width changes, including when fonts finish loading or a media query hides the switcher. - Clears the margin when leaving the route; it stays 0 while the switcher is hidden (e.g. on ≤768px screens), so the layout doesn't shift there.