Skip to content

Comments

Desktop, Mobile: Fixes #13258: Prevent new notes from being created in trashed or missing notebooks in certain cases#13575

Merged
laurent22 merged 5 commits intolaurent22:devfrom
mrjo118:prevent-new-notes-created-in-trash
Nov 15, 2025
Merged

Desktop, Mobile: Fixes #13258: Prevent new notes from being created in trashed or missing notebooks in certain cases#13575
laurent22 merged 5 commits intolaurent22:devfrom
mrjo118:prevent-new-notes-created-in-trash

Conversation

@mrjo118
Copy link
Contributor

@mrjo118 mrjo118 commented Oct 30, 2025

On both desktop and mobile, when switching to a notebook which is in the trash, then switching to the note list view by selecting a tag, the new note button allows you to create the note in the trashed notebook. This addresses the issue by setting the default notebook as the note parent if the current 'active notebook' is trashed or missing. In addition, the default notebook function is (incorrectly) able to return a notebook which is trashed, so I have amended this function to exclude trashed notebooks

This fixes #13258

Testing

Video before the change:

new.note.trashed.notebook.before.mp4

Video after on desktop:

new.note.trashed.notebook.after.mp4

Video after on mobile:

new.note.trashed.notebook.after.mobile.mp4

@mrjo118 mrjo118 changed the title Desktop, Mobile: Fixes #13258: Prevent new notes from being created in trashed notebooks in certain cases Desktop, Mobile: Fixes #13258: Prevent new notes from being created in trashed or missing notebooks in certain cases Oct 30, 2025
Comment on lines 18 to 26
let folderId = Setting.value('activeFolderId');
if (!folderId) return;

const folder = await Folder.load(folderId);
if (!folder || !!folder.deleted_time) {
const defaultFolder = await Folder.defaultFolder();
if (!defaultFolder) return;
folderId = defaultFolder.id;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole idea with this "activeFolderId" was to have a guaranteed, valid, target whenever a notebook is needed. It seems the concept is broken now since the introduction of the trash folder, and we don't want to have this checking logic duplicate everywhere.

Maybe an alternative would be to created a helper function like "getValidNotebook" that is guaranteed to return such a notebook?

Or maybe this command should just throw if someone attempts to create a notebook when the trash is selected?

In fact, based on newNoteEnabledConditions, this command is not even enabled in the trash, so maybe that's the issue, that it can be called even though it's disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Or maybe this command should just throw if someone attempts to create a notebook when the trash is selected?"

That's not really suitable, because the issue isn't when the 'trash' is selected, the issue is when a 'trashed notebook' is selected. The existing behaviour to prevent creating notebooks in the trash directly is working.

Using a helper method makes sense though.

@mrjo118
Copy link
Contributor Author

mrjo118 commented Nov 4, 2025

@laurent22 I've updated the PR to use a new helper function

@laurent22
Copy link
Owner

that looks good now, thank you!

@laurent22 laurent22 merged commit 2ab720f into laurent22:dev Nov 15, 2025
11 checks passed
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.

Creating a note when viewing a tag can cause the note to be created in a trashed folder

2 participants