Skip to content

[iOS] Native editor doesn't dismiss when the contact is deleted from it (iOS 26+) #250

Description

@liliana-tagonsoft

Description

On iOS, FlutterContacts.native.showEditor(contactId) presents a CNContactViewController with
allowsEditing = true. On iOS 26+ that editor offers a Delete Contact row at the bottom
(earlier iOS versions don't show it in a third-party editor, which is probably why this hasn't come
up before).

Deleting the contact from that row leaves the app stuck:

  1. contactViewController(_:didCompleteWith:) is never called, so the sheet stays on screen
    still rendering the contact that was just deleted.

  2. The showEditor Future doesn't complete until the user closes the sheet by hand. Because the
    controller is presented in editing mode it shows its own ✕ / ✓ items rather than the injected
    Done button, so ✕ is what the user ends up tapping — and the Future then resolves to null, the
    same value as "cancelled", so the caller has no way to know the contact is gone.

  3. Calling showEditor again for that id then throws:

    PlatformException(flutter_contacts_error, Updated Record Does Not Exist, null, null)
    

    because store.unifiedContact(withIdentifier:) in ShowEditorImpl.handle fails on the deleted
    identifier.

Steps to reproduce

  1. On iOS 26+, await FlutterContacts.native.showEditor(contactId: someExistingId).
  2. Scroll to the bottom of the editor, tap Delete Contact, confirm.
  3. Observe the sheet stays open on the deleted contact; close it by hand (✕).
  4. Call showEditor again with the same id.

Expected

The editor dismisses itself when the contact is deleted from it, and showEditor completes.

Actual

The sheet stays up until the user dismisses it by hand, showEditor resolves to null, and a
second call throws Updated Record Does Not Exist.

Environment

  • flutter_contacts 2.3.1
  • Flutter 3.44.1 (stable)
  • iOS 26.3 simulator (iPhone 17 Pro); also seen on a physical device

Fix

PR #249 observes .CNContactStoreDidChange while the editor is presented and dismisses it once the
edited contact no longer resolves. Verified on the iOS 26.3 simulator: delete now closes the sheet,
and normal save / cancel are unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions