Fix #98: comment can't be deleted via bulk edit - #199
Open
GlebYavorski wants to merge 1 commit into
Open
Conversation
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>
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
BulkEditModal.onSave—if (opts.tags || opts.comment)skipped the dispatch entirely when the only change was clearing the comment.modifyCommentin5-entities/transaction/thunks.ts—if (!newComment) return prevCommentrestored the previous comment even if the dispatch did happen.And a third, related one:
commentwas only initialised on mount.BulkEditModallives permanently in the tree (rendered byActionswithids={[]}before anything is selected), so the field started empty and then kept whatever was typed the previous time. TheuseEffectonopenresettagsbut notcomment.The fix
modifyCommentkeeps the previous comment only when the new one isundefined; an empty string clears it and is stored asnull, matching thecomment: string | nullconvention inmakeTransaction. The$&placeholder keeps working.BulkEditModalsendscommentonly 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.Tests
Added
thunks.test.tsandBulkEditModal.test.tsxcovering 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.tsxfails onmasteralready (itsvi.mock('i18next')has no default export, so6-shared/localizationblows up on import). Left it alone to keep this PR focused — happy to fix it separately if you'd like.🤖 Generated with Claude Code