Skip to content

Responsive 450 - #520

Merged
mudabs merged 3 commits into
oss-slu:mainfrom
Subomiadekunle:responsive-450
Nov 18, 2026
Merged

mudabs merged 3 commits into
oss-slu:mainfrom
Subomiadekunle:responsive-450

Conversation

@Subomiadekunle

@Subomiadekunle Subomiadekunle commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

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 current main plus #519: npm run lint clean; git diff --check upstream/main...HEAD clean; npx jest templates/tests/sceneAnnotationEditor.test.js --runInBand 123 passed; npm test -- --runInBand 22 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

    • In templates/js/scenes.js, initializeSceneEditor registers a ResizeObserver for handleCanvasResize on #scene-canvas.
    • watchTouchTargetScale also owns a reusable ResizeObserver for the current SVG.
    • In templates/tests/sceneAnnotationEditor.test.js, the responsive touch-scale test assumes every observer is the SVG observer and expects observers to have length one around lines 1748 to 1751.
    • The current run fails with Expected length: 1, Received length: 2. The second observer is the canvas resize observer.
    • Keep the observer responsibilities explicit. Either consolidate them intentionally, or update the test harness to identify the canvas observer separately from the reusable SVG observer.
    • The test must verify that the SVG observer is reused and retargeted to the newly rendered SVG, while the canvas observer remains attached to #scene-canvas. Do not weaken the assertion to only check that at least one observer exists.
  • Refresh the branch against current main

    • Update the branch with the latest main so GitHub recalculates mergeability.
    • Preserve the current pointer, touch, and stylus behavior from main.
    • Do not reintroduce duplicate prerequisite changes or remove the zoom, pan, and responsive resizing behavior from this PR.
  • Run validation on the final head

    • npm run lint
    • git diff --check
    • npx jest templates/tests/sceneAnnotationEditor.test.js --runInBand
    • npm test -- --runInBand
    • Update the testing section of the PR description so it reflects the actual results.

Once the observer test passes and the branch is refreshed against current main, please request another review.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. Please address the detailed follow-up items in the PR description, then request another review.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. Please address the detailed follow-up items in the PR description, then request another review.

Subomiadekunle and others added 3 commits November 17, 2026 23:47
…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.
@sonarqubecloud

Copy link
Copy Markdown

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The ResizeObserver test now distinguishes the canvas and SVG observers, the branch is based on current main, and local validation passes.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mudabs
mudabs merged commit cce7fbf into oss-slu:main Nov 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Small Rock] Support Responsive Resizing

2 participants