Skip to content

Don’t ask “Save draft?” unless the text has been edited #2

@roryokane

Description

@roryokane

When I open a draft by double-clicking it, then change my mind and hit Back without typing any text, I am still prompted with this alert:

Save draft?
[Discard] [Save]

This alert should only be shown if the text at the moment I hit Back is different from the text as it was when I first opened the draft.

For the Discard feature to work, you must already be saving the original text when I first open the draft. So this feature should only need one extra if, plus a call to your discard function in the alternative branch. In pseudo-code:

if (textField.currentValue.equals(draftModel.originalValue)) {
    discard();
} else {
    // show prompt and save or discard as you currently do
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions