Skip to content

Lock the visible-signature toggle to the selected field - #477

Merged
kwart merged 2 commits into
masterfrom
fix-visible-sig-field-toggle
Aug 8, 2026
Merged

Lock the visible-signature toggle to the selected field#477
kwart merged 2 commits into
masterfrom
fix-visible-sig-field-toggle

Conversation

@kwart

@kwart kwart commented Aug 7, 2026

Copy link
Copy Markdown
Member

Follow-up to #473 (sign into an existing signature field), from testing the feature.

The visible-signature toggle and the field selection disagreed

Selecting a field forces visible=true and disables the side-panel checkbox, but menuVisibleSig and btnVisibleSig stayed switchable. Unchecking them changed nothing about the output — SignerLogic.validateSigField() sets options.setVisible(true) for a field-placed signature regardless — it only flipped the status badge to "invisible signature". Both toggles now bind to noDocument.or(sigFieldSelected) and lock together with the checkbox. (create new field) is the way back to an invisible signature; a zero-size field rectangle still gives one anyway.

The blue box in the lower-left corner

Flipping the flag back on placed a 100×100pt rectangle at the page origin. onSigFieldSelected() resets the position options to DEFVAL_LLX..DEFVAL_URY (so the "position ignored" warning does not fire at signing time), and autoPlaceVisibleSignature() accepted that untouched default as a valid last-known position instead of falling through to its bottom-right default. This is not specific to the new feature — a fresh profile has never held any other coordinates, so the very first Visible signature toggle always landed in the lower-left corner.

The fits check was duplicated in VisibleSignatureCoordinator.pushSigningToPlacement() (the preset-load path, whose javadoc already claimed stale defaults were guarded against — they weren't). Both now call one hasUsablePosition() that rejects the default rectangle. autoPlaceVisibleSignature() additionally does nothing at all while a field is selected: the field's own /Rect decides the position, so a placement rectangle would only promise something the signing path ignores.

Deselecting a field left visible=ON with nothing on screen

The forced-on flag survives the deselection, so signing would have placed the appearance at the default coordinates with no rectangle drawn. Deselection now re-runs the auto-placement (guarded on hadField && visible, so document open/close — both of which clear visible first — are unaffected).

Verification

Driven headlessly through the real MainWindow.fxml controllers under Monocle, with a generated one-blank-field PDF:

NO FIELD: visible on   placed=true  rel=[0.800 0.870 ...]  <- bottom-right default, was [0.000 0.881 ...]
field selected         placed=false menuDisabled=true btnDisabled=true
menu re-check          placed=false                        <- no phantom box
field deselected       placed=true  rel=[0.800 0.870 ...]  toggles unlocked

Preferences turned out not to be involved: PreferencesController.persist() and refreshActiveEngineFromConfig() never touch the signing view model, and the box does not appear across a dialog round-trip.

5 new cases in VisibleSignatureCoordinatorTest; mvn test green across all modules. Docs and the 3.2.0 release notes updated — the lower-left box gets its own bullet since it is pre-existing behaviour, while the toggle lock is part of the unreleased feature.

Selecting an existing signature field forced the visible flag on and
disabled the side-panel checkbox, but the menu item and the toolbar
toggle stayed switchable. Turning them off changed nothing about the
output - SignerLogic sets visible=true for a field-placed signature
regardless - so the status badge just started disagreeing with the
signature that came out. Both toggles now lock together with the
checkbox; "(create new field)" is the way back to an invisible
signature.

Turning the flag back on then placed a 100x100 box in the lower-left
corner of the page: selecting a field resets the position options to
their defaults, and the auto-placement accepted that untouched default
rectangle as a last-known position. The same box appeared on a fresh
profile, which has never held any other coordinates. The default
rectangle is now recognised as "nothing chosen yet" by both the
auto-placement and the preset-load path, which carried a copy of the
check, so the intended bottom-right fallback applies. The
auto-placement also stays out of the way entirely while a field is
selected - the field's own /Rect decides where the signature goes.

Deselecting a field left the forced-on visible flag behind with no
rectangle on screen, which would have signed at the default
coordinates without showing anything; the rectangle now comes back
with it.
Comment thread distribution/doc/release-notes/3.2.0.md Outdated
@kwart
kwart merged commit 8bc630d into master Aug 8, 2026
1 check passed
@kwart
kwart deleted the fix-visible-sig-field-toggle branch August 8, 2026 08:42
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