[PR #1491] [CLOSED] fix: Preserve unsaved title changes when modifying tags in EditBookmarkDialog #1841

Closed
opened 2026-03-02 11:59:25 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/1491
Author: @AdrianAcala
Created: 5/29/2025
Status: Closed

Base: mainHead: 1339-Unsaved-Title-Changes-Lost-When-Modifying-Tags


📝 Commits (2)

  • ede83d0 chore: Fix formatting issues
  • 0bde864 fix: Preserve unsaved title changes when modifying tags. Fixes #1339

📊 Changes

13 files changed (+381 additions, -16 deletions)

View changed files

📝 apps/browser-extension/src/components/ui/dialog.tsx (+2 -2)
📝 apps/browser-extension/src/components/ui/popover.tsx (+1 -1)
📝 apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx (+5 -2)
📝 apps/web/components/dashboard/highlights/HighlightCard.tsx (+1 -1)
📝 apps/web/components/dashboard/preview/LinkContentSection.tsx (+1 -1)
📝 apps/web/components/ui/dialog.tsx (+2 -2)
📝 apps/web/components/ui/dropdown-menu.tsx (+2 -2)
📝 apps/web/components/ui/markdown/markdown-editor.tsx (+1 -1)
📝 apps/web/components/ui/popover.tsx (+1 -1)
📝 apps/web/components/ui/select.tsx (+1 -1)
📝 apps/web/components/ui/toast.tsx (+1 -1)
📝 apps/web/components/ui/tooltip.tsx (+1 -1)
packages/trpc/routers/bookmarks-edit-behavior.test.ts (+362 -0)

📄 Description

Description

This PR fixes an issue where unsaved title changes in the EditBookmarkDialog were being lost when users
added or removed tags. The form was resetting on every prop change, which caused any pending edits to be
discarded when the bookmark's tag list was updated.

Problem

When editing a bookmark:

  1. User opens the edit dialog and changes the title
  2. User adds or removes a tag (without saving the title change first)
  3. The title change is lost and reverts to the original value

Solution

Modified the form reset logic in EditBookmarkDialog to only reset when the dialog transitions from
closed to open, not on every prop change. This is achieved by:

  • Using a useRef to track the previous open state
  • Only resetting the form when open changes from false to true
  • Preserving form state during tag operations

Testing

Added comprehensive test coverage in bookmarks-edit-behavior.test.ts to verify:

  • Title edits are preserved when adding tags
  • Title edits are preserved when removing tags
  • Multiple title edits work correctly with tag updates in between
  • Other bookmark fields (note, summary, archived, favorited) are not affected
  • Special characters and Unicode in titles are handled correctly
  • Tag operations don't trigger unnecessary re-crawling
  • Bulk tag operations preserve custom titles

Changes

  • Modified form reset logic in EditBookmarkDialog.tsx to only reset on dialog open
  • Added comprehensive test suite for bookmark edit behavior
  • Fixed minor formatting issues in UI components to get the git precommit hook to pass.

Fixes #1339


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/1491 **Author:** [@AdrianAcala](https://github.com/AdrianAcala) **Created:** 5/29/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `1339-Unsaved-Title-Changes-Lost-When-Modifying-Tags` --- ### 📝 Commits (2) - [`ede83d0`](https://github.com/karakeep-app/karakeep/commit/ede83d0546ed330a252c1d5ddf0d2aa9781c0d46) chore: Fix formatting issues - [`0bde864`](https://github.com/karakeep-app/karakeep/commit/0bde8647b3a06a0ad110dfb1342e03a9b27bdeab) fix: Preserve unsaved title changes when modifying tags. Fixes #1339 ### 📊 Changes **13 files changed** (+381 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `apps/browser-extension/src/components/ui/dialog.tsx` (+2 -2) 📝 `apps/browser-extension/src/components/ui/popover.tsx` (+1 -1) 📝 `apps/web/components/dashboard/bookmarks/EditBookmarkDialog.tsx` (+5 -2) 📝 `apps/web/components/dashboard/highlights/HighlightCard.tsx` (+1 -1) 📝 `apps/web/components/dashboard/preview/LinkContentSection.tsx` (+1 -1) 📝 `apps/web/components/ui/dialog.tsx` (+2 -2) 📝 `apps/web/components/ui/dropdown-menu.tsx` (+2 -2) 📝 `apps/web/components/ui/markdown/markdown-editor.tsx` (+1 -1) 📝 `apps/web/components/ui/popover.tsx` (+1 -1) 📝 `apps/web/components/ui/select.tsx` (+1 -1) 📝 `apps/web/components/ui/toast.tsx` (+1 -1) 📝 `apps/web/components/ui/tooltip.tsx` (+1 -1) ➕ `packages/trpc/routers/bookmarks-edit-behavior.test.ts` (+362 -0) </details> ### 📄 Description ## Description This PR fixes an issue where unsaved title changes in the EditBookmarkDialog were being lost when users added or removed tags. The form was resetting on every prop change, which caused any pending edits to be discarded when the bookmark's tag list was updated. ## Problem When editing a bookmark: 1. User opens the edit dialog and changes the title 2. User adds or removes a tag (without saving the title change first) 3. The title change is lost and reverts to the original value ## Solution Modified the form reset logic in `EditBookmarkDialog` to only reset when the dialog transitions from closed to open, not on every prop change. This is achieved by: - Using a `useRef` to track the previous open state - Only resetting the form when `open` changes from `false` to `true` - Preserving form state during tag operations ## Testing Added comprehensive test coverage in `bookmarks-edit-behavior.test.ts` to verify: - Title edits are preserved when adding tags - Title edits are preserved when removing tags - Multiple title edits work correctly with tag updates in between - Other bookmark fields (note, summary, archived, favorited) are not affected - Special characters and Unicode in titles are handled correctly - Tag operations don't trigger unnecessary re-crawling - Bulk tag operations preserve custom titles ## Changes - Modified form reset logic in `EditBookmarkDialog.tsx` to only reset on dialog open - Added comprehensive test suite for bookmark edit behavior - Fixed minor formatting issues in UI components to get the git precommit hook to pass. Fixes #1339 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:59:25 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1841
No description provided.