How to ignore a dirty state when canceling

Continuing the discussion from Closing a read-only document with editable transient field without a warning:

The warning relates to canceling out of a dirty form. The form is dirty because the user has interacted with controls which reference transient fields.

What’s the best way to proceed:

  • Use a custom event?
  • Customize the View?
  • ..

For a generic solution do the following:

  • Create a generic event name e.g. force_cancel.
  • Create a middleware that reacts to this event.
  • Dispatch ActivityActions.cancel action.

This does not trigger any dirty handling (see here).