Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Image editor asks "Discard changes?" after a successful save (SET_SAVED does not restore isResetted)

Open
#3,425 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react
Domain
frontend

Research direction

The issue points to the bundled react-filerobot-image-editor state handling in actions/setSaved.js and the close guard in components/Topbar/ConfirmationModal.js; first trace how SET_SAVED and isResetted determine the close behavior. Reproduce by editing and saving an image, then closing the editor. Done means a successful save closes without a discard prompt, while unsaved edits still prompt.

Written by the indexing model from the issue text.

Description

Bug description

After saving an image successfully in the built-in image editor
(viewer 5.0.0, NC 32.0.14.1), closing the editor still shows the confirmation
dialog "Discard changes? / Are you sure you want to continue?"
(German UI: "Änderungen verwerfen – Sind Sie sich sicher, dass Sie fortsetzen
wollen?"
), although there is nothing left to discard.

The user has already saved, so the prompt is misleading – people press
"Cancel"/"Abbrechen" and think their edit is at risk, or press "Confirm" and get
the impression the save did not happen.

Steps to reproduce
  1. Open any image in the viewer, Ctrl+E (or ?editing=true) to open the editor.
  2. Apply a change (e.g. Filters → Black & White).
  3. Save → "Save image as" dialog → Save → confirm overwrite.
    Success toast "Image saved" is shown, and the upload (PUT → 204) worked.
  4. Close the editor (top-right ✕, Esc, or the close button).

Actual: the "Discard changes?" confirmation dialog appears.
Expected: the editor closes immediately.

Root cause

react-filerobot-image-editor keeps two independent flags:

  • useAppReducer (any modification): isResetted: false, haveNotSavedChanges: true
  • actions/setSaved.js (SET_SAVED, dispatched after a successful save):
export var SET_SAVED = 'SET_SAVED';
var setSaved = function (state) {
  return state.haveNotSavedChanges
    ? { ...state, haveNotSavedChanges: false }   // <-- isResetted stays false!
    : state;
};
  • actions/reset.js (RESET) is the only action that sets isResetted: true.

The close button is wrapped in components/Topbar/ConfirmationModal.js:

React.cloneElement(children, {
  onClick: isResetted !== undefined ? isResetted : true ? closeDirectly : openModal,
})

i.e. the dialog is opened whenever isResetted === false – it is not gated on
haveNotSavedChanges. After SET_SAVED the state is therefore
{ haveNotSavedChanges: false, isResetted: false } → the prompt is shown even
though there are no unsaved changes.

(The same happens for the reset button label/state and for Ctrl+S → close.)

Expected behaviour

Either setSaved should restore isResetted: true, or ConfirmationModal
should ask only when there actually is something to discard:

onClick: !isResetted && haveNotSavedChanges ? openModal : closeDirectly
Environment
  • Nextcloud 32.0.14.1, viewer 5.0.0 (bundled react-filerobot-image-editor)
  • Chrome 155 / Linux, German UI (reproduced with English strings as well)
  • Happens for every format, not only .JPG
Dominant language
JavaScript
Stars
121
Forks
70
Avg merge
1d 6h
Merged PRs (30d)
16

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/viewer

All issues in nextcloud/viewer

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.