fix: correct requestScrollTo scroll offset calculations#2927
Open
cqnykamp wants to merge 1 commit into
Open
Conversation
- AssignmentResponseStudent: fix FIXED_OFFSET from 0 to 90 and point viewerContainer ref at the actual viewer Box instead of the outer GridItem, so the scroll target position is calculated correctly - AssignmentItemResponseStudent: accept optional viewerContainerRef prop and attach it to the viewer Box so the parent can measure its position - DocEditorViewMode: use dynamic headerHeight instead of hardcoded 90 so scroll works correctly when the notBrowsable warning banner is shown (headerHeight becomes 120px, adding 40px to the fixed header) Fixes #2604 https://claude.ai/code/session_01JMg997rhUoDWpN7mscG1eJ
Contributor
Author
|
The My changes only touch three files:
None of these files are imported or referenced by any All other CI checks (e2e groups 1–4, brittle groups 1–3, component groups 2–4, and the format/lint/build/unit check) either passed or are still running. Generated by Claude Code |
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.
Summary
Fixes #2604 —
requestScrollToscroll offset calculations were incorrect in two places, causing DoenetML content to scroll to the wrong position when the viewer requests a scroll (e.g., when navigating to an answer or hint).AssignmentResponseStudent.tsx: TheFIXED_OFFSETwas0(a placeholder- 0) instead of90, causing content to scroll too far down. Additionally, theviewerContainerref was attached to the outer<GridItem area="centerContent">rather than the actual viewerBox, sogetBoundingClientRect().topmeasured the wrong element and the scroll target was miscalculated.AssignmentItemResponseStudent.tsx: Added an optionalviewerContainerRefprop (forwarded to the viewerBox) soAssignmentResponseStudentcan measure the correct element.DocEditorViewMode.tsx: The offset was hardcoded as90(matching the normal 80px header + 10px margin), but whennotBrowsable=truea 40px warning banner is added makingheaderHeight="120px". The hardcoded value caused the scroll target to land 30px above the visible area. Changed toparseInt(headerHeight) + 10to use the dynamic value.Test plan
AssignmentResponseStudent) and verify scroll-to worksnotBrowsable=true) and verify scroll-to works correctly with the taller headerNotes
Cypress component tests could not be run locally (binary unavailable in this environment). TypeScript (
tsc --noEmit) and ESLint both pass. CI will run the full test suite.The existing
cy.get("iframe").eq(0).scrollIntoView()workaround inassignmentWorkflow.cy.ts(around lines 364–394) is a separate pre-existing issue related to@doenet/assignment-viewer(DoenetActivityViewer) behavior when creating new item attempts — not addressed by this PR.https://claude.ai/code/session_01JMg997rhUoDWpN7mscG1eJ
Generated by Claude Code