Desktop: Maintain selection when non-selected note is deleted #2290
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.
Issue
The issue was raised here: forum thread
The issue is that in the note list, when a note is selected and another is deleted, the selection is changed.
In my opinion, it should not. The selection should only change if the selected note/s is deleted.
Solution
The change is implemented by adjusting the logic in the reducer's
handleItemDelete
. As a result, this change addresses the same issue that exists for notes, notebooks and tags.Testing
No unit tests existed for the reducer so new unit tests are created here. These unit tests only cover the functionality affected by this change. Manual testing was done on the desktop client.
Alternative solution
An alternative solution would be to change the behaviour of the right-click action so that right-clicking on a note selects it (in addition to the usual function of displaying the context menu).