Skip to content

fix(categories): keep notes when deleting a category#1927

Open
MiMoHo wants to merge 1 commit into
nextcloud:mainfrom
MiMoHo:fix/delete-category-keeps-notes
Open

fix(categories): keep notes when deleting a category#1927
MiMoHo wants to merge 1 commit into
nextcloud:mainfrom
MiMoHo:fix/delete-category-keeps-notes

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Deleting a category currently deletes the category folder including all note files inside it — a single confirmation click can destroy many notes. This change makes "Delete category" keep the notes: they are moved to Uncategorized instead, and only the empty folder goes away.

How it works

  • All notes of the category (including subcategories) are moved to the notes root via the existing per-note category mechanism (Note::setCategory('')), so file name collisions are resolved the same way as when changing a single note's category (Title (2).md).
  • Afterwards, only folders that contain no files at all are removed (new helper deleteFoldersWithoutFiles). Non-note files that happen to live in the category folder are never deleted.
  • The confirmation dialog and the client-side store update reflect the new behavior.

Note on the behavior change

This intentionally changes the semantics of an existing action, based on the expectation that "deleting a folder" should not silently destroy its notes. If you would rather keep the destructive delete and offer a choice (e.g. "delete notes" vs. "keep notes"), I am happy to rework this accordingly.

Testing

  • Verified end-to-end on Nextcloud 35 (dev): category folder removed, all notes kept, a colliding file name was renamed to Name (2).md, non-note files untouched.
  • php -l clean, production webpack build clean.

🤖 AI (if applicable)

  • This pull request was prepared with assistance from Claude Code (Claude Fable 5 xhigh).
    I reviewed and tested the changes myself.

Deleting a category previously deleted the category folder including
all note files in it. Move all notes of the category and its
subcategories to the uncategorized root folder instead, reusing the
per-note category move which resolves file name collisions. Only
folders that contain no files at all are removed afterwards, so
non-note files are never deleted.

The confirmation dialog and the client-side store update reflect the
new behavior: notes are kept and reassigned to Uncategorized.

Assisted-by: Claude Code:claude-fable-5
AI-assistant: Claude Code 2.1.187 (Claude Fable 5)
@MiMoHo MiMoHo requested review from enjeck and silverkszlo as code owners July 6, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant