Repository navigation
Responsive 450 - #520
Responsive 450#520
Conversation
mudabs
left a comment
There was a problem hiding this comment.
Thank you @Subomiadekunle for the responsive resizing updates and the added coverage for narrow layouts, zoomed views, touch targets, and interrupted drags. The implementation is well tested, but please address this issue before approval:
- Preserve the viewport when a line or arrow is being drawn during a resize.
- In templates/js/scenes.js, handleCanvasResize() captures the SVG around lines 682–688 before calling activeDrag.finish().
- Finishing a line or arrow drag calls addAnnotation(), which rerenders the workspace and replaces the SVG.
- The resize handler then uses the detached SVG reference with the updated viewCenter.
- In the browser, the detached SVG may report a zero-sized bounding rectangle, causing the scroll correction to calculate an incorrect position and make the canvas jump.
- Please save the current view center before finishing the drag, then reacquire the current SVG after activeDrag.finish() before applying the scroll correction.
- Add a regression test in templates/tests/sceneAnnotationEditor.test.js.
- Start drawing a line or arrow.
- Resize the canvas before releasing the drag.
- Confirm the annotation is finalized and the same scene region remains visible.
The local validation is currently clean:
- npm run lint
- git diff --check
- npm test -- --runInBand
- 22 test suites passed
- 854 tests passed, 5 skipped
5ffb31c to
88cb65d
Compare
mudabs
left a comment
There was a problem hiding this comment.
Changes requested. Please address the detailed follow-up items in the PR description, then request another review.
mudabs
left a comment
There was a problem hiding this comment.
Changes requested. Please address the detailed follow-up items in the PR description, then request another review.
…e test (oss-slu#450) The editor now has two ResizeObservers: one on #scene-canvas for layout changes and one reusable observer on the current SVG for touch-target scaling. The test assumed every observer was the SVG one. It now identifies each by what it observes and checks that there is exactly one of each, that the SVG observer is reused and retargeted to the newly rendered SVG, and that the canvas observer stays on #scene-canvas.
046818c to
30a1860
Compare
|
mudabs
left a comment
There was a problem hiding this comment.
Approved. The ResizeObserver test now distinguishes the canvas and SVG observers, the branch is based on current main, and local validation passes.
mudabs
left a comment
There was a problem hiding this comment.
Approved. PR 520 is technically ready to merge.
- ResizeObserver test fix verified
- Branch is based on current main
- Focused tests: 3 suites, 181 passed
- Full suite: 22 suites, 908 passed, 5 skipped
- Lint and diff checks pass
- GitHub checks pass
- Mergeable status: MERGEABLE



Closes #450 (part of #445). Builds on #519 (and the PRs it includes). Please review that first; this PR’s diff includes its commits until it’s merged. What’s new When the editor changes size (a resized window, a rotated phone or tablet): Objects stay aligned. Images and annotations keep their scene positions and are drawn in one SVG that scales as a whole, so labels, lines and highlights stay on the same spots of the image. The view stays put. When zoomed, the same part of the scene stays in the middle of the view instead of jumping elsewhere. A drag in progress ends where it is. Its screen-to-scene scale belonged to the old size, so continuing would have moved the object the wrong distance. Handles stay touch-sized for the new canvas size. Narrow layouts Less padding around the editor on screens up to 768px wide, so the canvas gets more of the width (303px instead of 271px on a 375px phone). The “Ctrl + scroll…” hint is hidden on touch screens. Testing
Tests added or updated in
templates/tests/sceneAnnotationEditor.test.js: the scene drawn once, aligned and unchanged at narrow and wide sizes; handle sizes updating; the zoomed view keeping its center; a drag ending on resize; a drag continuing when only the height changes; the narrow-screen styles; and the touch-target scale test, which now tracks the canvas observer (on#scene-canvas) and the reusable SVG observer separately and checks that the SVG observer is reused and retargeted after re-rendering.Run on head
30a1860, rebased on currentmainplus #519:npm run lintclean;git diff --check upstream/main...HEADclean;npx jest templates/tests/sceneAnnotationEditor.test.js --runInBand123 passed;npm test -- --runInBand22 suites passed, 908 tests passed, 5 skipped. Not checked on real devices or browsers.Review follow-up
Thank you @Subomiadekunle for the responsive resizing implementation and the additional coverage. The earlier line and arrow viewport issue appears addressed by commit
88cb65d, and its regression test passes. One blocker remains:Fix the failing ResizeObserver regression
templates/js/scenes.js,initializeSceneEditorregisters aResizeObserverforhandleCanvasResizeon#scene-canvas.watchTouchTargetScalealso owns a reusableResizeObserverfor the current SVG.templates/tests/sceneAnnotationEditor.test.js, the responsive touch-scale test assumes every observer is the SVG observer and expectsobserversto have length one around lines 1748 to 1751.Expected length: 1, Received length: 2. The second observer is the canvas resize observer.#scene-canvas. Do not weaken the assertion to only check that at least one observer exists.Refresh the branch against current main
mainso GitHub recalculates mergeability.main.Run validation on the final head
npm run lintgit diff --checknpx jest templates/tests/sceneAnnotationEditor.test.js --runInBandnpm test -- --runInBandOnce the observer test passes and the branch is refreshed against current
main, please request another review.