Skip to content

Add confirmation before deleting individual notes - #2138

Merged
juliusknorr merged 3 commits into
nextcloud:mainfrom
Mahsakohan:safer-note-deletion
Nov 18, 2026
Merged

juliusknorr merged 3 commits into
nextcloud:mainfrom
Mahsakohan:safer-note-deletion

Conversation

@Mahsakohan

@Mahsakohan Mahsakohan commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

No confirmation for deleting a note#1548

Changes

  • Added a confirmation dialog before deleting a note, using showConfirmation from @nextcloud/dialogs.
  • Added a confirmation message including the note title.
  • Updated the Delete note text and icon using var(--color-text-error) and DeleteOutlineIcon to make the action more noticeable, and used NcLoadingIcon to indicate the loading state.
  • Kept the existing deletion and Undo functionality unchanged.

UX decisions

  • I added the confirmation dialog to prevent accidental deletion. It adds an extra click when deleting a note, but gives users a chance to cancel.
  • I kept the existing Undo feature so users can still restore a note after deletion.

Testing

  • Updated the existing Playwright deletion test to check the confirmation dialog and note title, while keeping the existing Undo check.
  • Added a Playwright test to check that Cancel closes the dialog without deleting the note.
  • All 4 Playwright tests passed.
  • npm test: 87 tests passed.
  • npm run lint: 0 errors, 3 warnings.
  • npm run stylelint: passed.
  • TESTING=true npm run build: passed with 2 asset-size warnings.
  • I chose these tests to make sure notes are not deleted before confirmation, Cancel keeps the note, and Undo still works.
  • I also checked the confirmation dialog, Cancel, and Delete actions manually in the browser.

Limitations and observations

  • When deleting the only remaining note, I noticed that Undo takes a few seconds to show the note again. I didn't notice this delay when there were multiple notes and I deleted one of them. I didn't investigate this further.
  • Docker reported an HTTP 409 error when stopping the test container, although the Playwright tests passed.
  • ESLint reported 3 warnings in EditorEasyMDE.vue, which I didn't modify.

🤖 AI

  • The content of this PR was partly or fully generated using AI (N/A)
    I used ChatGPT to help write the Playwright tests and some CSS code. I reviewed the code and ran the tests myself.

@juliusknorr juliusknorr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot for this. The tests are a good addition 👍 I left some comments inside, mostly about reusing what we already have. Otherwise only those two left as general note:

  • DCO check is failing: please sign off your commits (git commit -s), add the Assisted-by: trailer from AGENTS.md since AI was used, and squash into one feat: commit.
  • The slow undo when deleting the last note is a good catch. Mind opening a separate issue for it?

Comment thread src/components/NoteItem.vue Resolved
Comment thread src/components/NoteItem.vue Resolved
Comment thread src/components/NoteItem.vue Resolved
Comment thread src/components/NoteItem.vue Resolved
Comment thread assessment-notes.md Resolved
@juliusknorr juliusknorr added enhancement New feature or request AI assisted This PR contains AI-assisted commits labels Nov 16, 2026
Assisted-by: ChatGPT:GPT-6
Signed-off-by: Mahsa Kohan <mahsaa.kohan@gmail.com>

@juliusknorr juliusknorr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick update, looks good now 👍 Mind still opening a separate issue for the slow undo on the last note?

@juliusknorr juliusknorr added 4. to release feature: app navigation Related to the app navigation labels Nov 16, 2026
@Mahsakohan

Copy link
Copy Markdown
Contributor Author

Thank you @juliusknorr for reviewing and approving the PR.
I have created a separate issue for the slow Undo behaviour when deleting the last note: #2139

@silverkszlo

Copy link
Copy Markdown
Contributor

Hey @Mahsakohan , thank you for that nice contribution! I think I have found a bug though: When clicking on the 'close'/X button of the dialog, I get this warning in the console:

Screenshot from 2026-11-17 11-34-18

And when I close the dialog via the 'escape' key, I get this error:

Screenshot from 2026-11-17 11-34-38

@silverkszlo silverkszlo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and another small bug that Claude pointed me to:

The note title is HTML-escaped twice (NoteItem.vue:345):
this.t is Nextcloud core's global t. It HTML-escapes placeholder values by default (options.escape = true, see server/core/src/OC/l10n.js). The dialog then shows text as plain text (textContent), so a note called Tom & Jerry appears as Delete note "Tom & Jerry"?. Pass { escape: false } as the 4th argument:

text: this.t('notes', 'Delete note "{title}"?', { title: this.note.title }, undefined, { escape: false }),

I have tested it in the UI:

Screenshot from 2026-11-17 11-48-48

Signed-off-by: Mahsa Kohan <mahsaa.kohan@gmail.com>
Signed-off-by: Mahsa Kohan <mahsaa.kohan@gmail.com>
@Mahsakohan

Copy link
Copy Markdown
Contributor Author

Hey @silverkszlo,
Thank you for the review and feedback.
Both issues have been fixed and pushed.

  • Dialog closing error: The issue was caused by an unhandled promise rejection. I fixed it by handling the Dialog closed error in a try/catch block.
  • Double HTML escaping: The note title was being escaped by the translation function. I fixed it by setting escape: false.

@silverkszlo silverkszlo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice one, thank you! :)

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@juliusknorr
juliusknorr merged commit 56d7c7c into nextcloud:main Nov 18, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release AI assisted This PR contains AI-assisted commits enhancement New feature or request feature: app navigation Related to the app navigation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants