Bug 504490

Summary: After sending files to Trash, Dolphin selects files randomly
Product: [Applications] dolphin Reporter: Patrick Silva <bugseforuns>
Component: view-engine: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: john.kizer, kde, kfm-devel
Priority: NOR    
Version First Reported In: 25.04.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: screen recording

Description Patrick Silva 2025-05-18 19:28:21 UTC
Created attachment 181475 [details]
screen recording

SUMMARY
I can't reproduce this bug consistently, but it occurs often after the steps below.

STEPS TO REPRODUCE
1. open a folder containing several files
2. select some files randomly, with ctrl+click
3. send the selected files to Trash by pressing del key

OBSERVED RESULT
after sending the selected files to Trash, Dolphin unexpectedly selects other files randomly. Please watch the attached screen recording.

EXPECTED RESULT
no file should be selected after the provided steps

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.3.90
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0
Graphics Platform: Wayland
Comment 1 John Kizer 2025-05-22 05:27:21 UTC
I can reproduce on today's git master. Thanks!
Comment 2 John Kizer 2025-06-20 04:29:55 UTC
*** Bug 505485 has been marked as a duplicate of this bug. ***
Comment 3 Bug Janitor Service 2025-09-10 13:51:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/1051
Comment 4 Méven 2025-09-21 10:29:00 UTC
Git commit 76a79ba3e8660e9fdfd8e897c69065e79721545e by Méven Car.
Committed on 21/09/2025 at 08:40.
Pushed by meven into branch 'master'.

dolphinview: position the focus after the last removed file

Previously, the code could misposition the selection after removal if
the last file in the view was removed and several files were selected.

And since it didn't clear the selection, the previous selection
influence the selection.

Instead clear the selection and position only the focus, either on the
next item after the last index, or the last item still in the view if the last
item was removed.

M  +4    -8    src/views/dolphinview.cpp

https://invent.kde.org/system/dolphin/-/commit/76a79ba3e8660e9fdfd8e897c69065e79721545e