Never reset on the Cancel button function. Then, clicking the X (or escape if enabled) doesn't call this function.
I've generally been doing reset right before the dialog is opened. Here that would be at the top of the `addAction` function. But it could also be done on the UI dialog's `open` or `close` function I think.