[Bug]: Image editor asks "Discard changes?" after a successful save (SET_SAVED does not restore isResetted)
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
- Open any image in the viewer,
Ctrl+E(or?editing=true) to open the editor. - Apply a change (e.g. Filters → Black & White).
- Save → "Save image as" dialog → Save → confirm overwrite.
Success toast "Image saved" is shown, and the upload (PUT→204) worked. - 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: trueactions/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 setsisResetted: 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,
viewer5.0.0 (bundledreact-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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/viewer
-
[Bug]: Image editor silently writes PNG data into .JPG files (uppercase extension breaks canvas.toBlob MIME)Possibly taken @aniruddh18122006-cyber claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/viewer#3424 · 3 comments ·
Maintainers usually reply within 1 day
-
3. to review
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
nextcloud/viewer#3196 · 2 comments ·
Maintainers usually reply within 1 day
-
0. Needs triage bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
nextcloud/viewer#3343 · 2 comments ·
Maintainers usually reply within 1 day
-
0. Needs triage enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Maintainers usually reply within 1 day
All issues in nextcloud/viewer
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
no-human-ai/no_human#659 ·
Maintainers usually reply within 1 day
-
[BUG] Multi-day events show "Ended" while still in progressPossibly taken @tarunagnihotri534 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
data-umbrella/du-event-board#231 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
IO.get_env on Node truncates names at embedded NULPossibly taken @Yi-111-a claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HigherOrderCO/Bend#1449 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
cryptpad/documentation#162 ·