Skip to content

NO-2077: sync SignatureView URL state and avoid duplicate change events#312

Open
vivekjyani wants to merge 2 commits intomainfrom
NO-2077
Open

NO-2077: sync SignatureView URL state and avoid duplicate change events#312
vivekjyani wants to merge 2 commits intomainfrom
NO-2077

Conversation

@vivekjyani
Copy link
Copy Markdown
Contributor

1) Spec Context

This change continues the ChangeHandler behavior work for Signature fields. The goal is to keep mirrored signature fields in sync while preventing redundant onChange emissions when state already matches.

2) What Changed (Files/Code)

  • Sources/JoyfillUI/View/Fields/SignatureView.swift
    • Added a guard in .onChange(of: signatureURL) to skip firing eventHandler.onChange(...) when the value is already equal to signatureDataModel.signatureURL.
    • Added .onChange(of: signatureDataModel.signatureURL ?? "") to sync external/model-driven updates back into local view state (signatureURL and signatureImage) and refresh the rendered image.
  • JoyfillSwiftUIExample/JoyfillUITests/ChangeUITests/OnChangeHandlerUITests.swift
    • Added testSignatureCoordinatess() (iPad) to validate that updating one signature field reflects on its mirrored counterpart.

3) Key Implementation Decisions

  • Used value-equality guards before emitting change events to avoid duplicate events and potential event loops.
  • Added a model-to-view sync onChange path so UI state stays correct even when updates originate outside the local control path.
  • Kept the logic in SignatureView to localize signature-specific synchronization behavior and minimize side effects.

4) Screenshot / Video

No screenshot/video attached in this PR. This is a targeted behavior fix with UI test coverage.

5) Public API / Docs

  • Public API changes: None.
  • Docs update required: No.

6) Test Coverage

  • Added UI test coverage for mirrored signature propagation behavior.
  • Scope note: this covers the signature sync path exercised in iPad UI flow; no additional unit tests were added in this PR.

7) Reviewer Notes

  • Please focus review on duplicate-event prevention and model-to-view synchronization behavior in SignatureView.
  • If helpful, I can follow up with a small cleanup PR to standardize naming in the new test method.

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.

1 participant