Skip to content

Fix #98: comment can't be deleted via bulk edit - #199

Open
GlebYavorski wants to merge 1 commit into
ardov:masterfrom
GlebYavorski:fix/98-clear-comment-in-bulk-edit
Open

Fix #98: comment can't be deleted via bulk edit#199
GlebYavorski wants to merge 1 commit into
ardov:masterfrom
GlebYavorski:fix/98-clear-comment-in-bulk-edit

Conversation

@GlebYavorski

Copy link
Copy Markdown

Fixes #98.

What happens

Erasing a comment in the Edit transactions dialog (select transactions → Actions → Edit) silently does nothing — the transaction keeps its old comment. On top of that, the dialog never shows the comment of the currently selected transactions, which is the second half of the report ("при редактировании операции комментарий не отображается").

Editing the same transaction through the transaction preview panel works fine, which is why the bug only shows up on this path.

Root cause

An empty string was treated as "no change" in two independent places:

  1. BulkEditModal.onSaveif (opts.tags || opts.comment) skipped the dispatch entirely when the only change was clearing the comment.
  2. modifyComment in 5-entities/transaction/thunks.tsif (!newComment) return prevComment restored the previous comment even if the dispatch did happen.

And a third, related one: comment was only initialised on mount. BulkEditModal lives permanently in the tree (rendered by Actions with ids={[]} before anything is selected), so the field started empty and then kept whatever was typed the previous time. The useEffect on open reset tags but not comment.

The fix

  • modifyComment keeps the previous comment only when the new one is undefined; an empty string clears it and is stored as null, matching the comment: string | null convention in makeTransaction. The $& placeholder keeps working.
  • BulkEditModal sends comment only when it differs from the common comment of the selection — the same guard tags already use. So hitting Save without touching the field never overwrites anything, including when a mixed selection shows an empty field.
  • The comment field is reset when the dialog opens, so it shows the actual comment of the selected transactions.

Tests

Added thunks.test.ts and BulkEditModal.test.tsx covering set / clear / untouched / $& placeholder. Both fail before the change and pass after.

Also verified by hand in demo mode: clearing a comment now removes it from the list immediately, and other transactions are untouched.

Note: src/5-entities/tag/ui/TagSelect2.test.tsx fails on master already (its vi.mock('i18next') has no default export, so 6-shared/localization blows up on import). Left it alone to keep this PR focused — happy to fix it separately if you'd like.

🤖 Generated with Claude Code

Erasing the comment in the bulk edit dialog had no effect: an empty
string was treated as "no change" in two places, so the comment stayed
on the transaction.

- `modifyComment` now only keeps the previous comment when the new one
  is `undefined`; an empty string clears it (stored as `null`).
- `BulkEditModal` no longer skips the dispatch for an empty comment. It
  sends the comment only when it differs from the common one, mirroring
  how tags already work, so untouched fields never overwrite anything.
- The comment field is also reset when the dialog opens. Before, it kept
  the value from the previous session and never showed the comment of
  the selected transactions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@GlebYavorski is attempting to deploy a commit to the Alexey Ardov's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

[beta] Не обновляется комментарий операции при его удалении

1 participant