CP-14535 - Deduplicate signature pad canvas sizing across the four pads - #88
Merged
Merged
Conversation
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.
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 existingcrop_canvas.jsshared-module convention. All four pads now call the samesetupCanvasSizing(options)with their own options object:submission_form/signature_step.vue,initials_step.vue): width-derived height via their existingcanvasHeightForWidth(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.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./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