M7: locking a signature clears the comment selection (#2149)

Review follow-up on #2348: flatten_fill_sign_in refreshed the view after Edit::FlattenFillSign but kept view.comments.selected. The placed signature is usually the selected comment, and once it is part of the page its (page, index) names nothing, or another comment after the indices shift. Both Lock now and the save-time Lock and save go through flatten_fill_sign_in, so both clear it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
This commit is contained in:
mtlcl410andClaude Opus 5.5 committed 2026-11-02 08:31:10 +08:00
1 parent 78e15fc4cf
commit a06ff3769f
2 files changed
+19

No files matched your search

+3
View File
@@ -226,6 +226,9 @@ impl PdfCraftApp {
&& let Some(view) = self.views.iter_mut().find(|v| v.id == id)
{
view.document_changed(&doc.info);
// The marks left the comments: a selected one is gone, and its (page, index) could
// now name another comment.
view.comments.selected = None;
}
true
}
+16
View File
@@ -1895,6 +1895,22 @@ fn placing_a_signature_offers_to_lock_it_now() {
assert!(h.query_by_label(NOTICE).is_none(), "a signed document isn't offered the lock");
}
/// #2348 review: locking takes the placed signature out of the comments, so its selection goes
/// too; a stale (page, index) would point at nothing, or at another comment.
#[test]
fn locking_a_signature_clears_the_comment_selection() {
let mut h = harness();
h.state_mut().signature = Some(SavedSig::Typed("Ada Lovelace".into()));
h.state_mut().execute("sign.fill.signature");
h.run_steps(2);
click(&mut h, 40.0, 300.0);
h.run_steps(2);
assert!(h.state().views[0].comments.selected.is_some(), "the placed signature is selected");
h.get_by_label("Lock now").click();
h.run_steps(3);
assert!(h.state().views[0].comments.selected.is_none(), "nothing left to select");
}
/// #2348 review: when locking the signature fails (here the document's security allows comments
/// but not changes), nothing is lost: the next save asks again, and "Don't ask again" isn't
/// remembered.