Skip to content

CP-14535 - Deduplicate signature pad canvas sizing across the four pads - #88

Merged
bernardodsanderson merged 2 commits into
mainfrom
CP-14535
Sep 16, 2026
Merged

bernardodsanderson merged 2 commits into
mainfrom
CP-14535

Conversation

@bernardodsanderson

@bernardodsanderson bernardodsanderson commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

CP-14535 - Deduplicate signature pad canvas sizing across the four pads

What

Extracts the canvas resize-on-orientation lifecycle (setup / teardown / resizeCanvas plus the double-rAF debounce handler) that PR #79 (CP-14191) copy-pasted into four signature pads into one shared module, app/javascript/submission_form/canvas_sizing.js, following the existing crop_canvas.js shared-module convention. All four pads now call the same setupCanvasSizing(options) with their own options object:

  • Vue pair (submission_form/signature_step.vue, initials_step.vue): width-derived height via their existing canvasHeightForWidth (3:1 / 4.5:1), uniform stroke ratio, persistent IntersectionObserver (re-sizes when a minimized/hidden field becomes visible), typed-signature re-render after resize.
  • Custom elements (draw.js <draw-signature>, elements/signature_form.js <signature-form>): height read from the live parent box, per-axis stroke ratios.

Net −221 lines (5 files, +175/−396). The "Double rAF: orientationchange fires before layout has settled" comment now lives exactly once — it had drifted into only the two Vue files, the drift flagged in the #79 review.

Why

After CP-14191 the next tweak to canvas sizing would have to land in four places, and drift was already visible (the double-rAF comment existed only in the Vue pair). This is the maintainability follow-up Paul suggested in the PR #79 review: pull the shared lifecycle into one place so future fixes land once. Pure refactor with zero behavior change — landscape/portrait finger alignment, stroke preservation on rotation, typed-text re-render, and teardown on unmount are preserved exactly; the intentional per-stack differences (height source, ratio style, Vue-only observers/typed restore) are parameterized options instead of divergent copies.

How to test

  • bundle exec rspec spec/system/signing_form_spec.rb — draw + typed signature flows (cuprite, js_errors: true); passes 24 examples, 0 failures on this branch.
  • yarn eslint — clean on the touched files.
  • Manual orientation check (no automated coverage exists): start the app, open a signing form (/s/:slug) and the mobile full-page draw pad (/d/:slug/sign), draw a stroke, rotate landscape ⇄ portrait — strokes should stay under the finger and survive rotation; typed signatures re-render after rotation; no console errors.

https://careerplug.atlassian.net/browse/CP-14535

@jewls618 jewls618 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like a clean clean-up 👍

@bernardodsanderson
bernardodsanderson merged commit 1d9d1c9 into main Sep 16, 2026
5 checks passed
@bernardodsanderson
bernardodsanderson deleted the CP-14535 branch September 16, 2026 18:19
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.

2 participants