Bug 409540

Summary: Focus doesn't move between UI elements in a logical way
Product: [Frameworks and Libraries] frameworks-kio Reporter: skierpage <info>
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs-null, nate, redashesyellowflowers
Priority: NOR Keywords: accessibility, usability
Version First Reported In: 5.59.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=466209
Latest Commit: Version Fixed/Implemented In: 6.11
Sentry Crash Report:

Description skierpage 2019-07-05 23:54:11 UTC
SUMMARY
In the Save As... dialog of at least Spectacle and KWrite, the tab key advances between widgets haphazardly, then after the Folder path field is focused it gets "stuck" in three widgets.

STEPS TO REPRODUCE
1. Open Spectacle, take screenshot, click [Save As...].
2. Press <tab> until the Folder path field above the directory listing is selected.
3. Now try to tab to the Name field.

OBSERVED RESULT
The tab field order is inconsistent. It starts in Name then File type - (skips Automatically select filename extension) - Icon size control - Places - Save - Cancel - Directory contents listing - Folder path field.

Once the focus has landed in the Folder path field, tabbing only advances among the folder path, the directory contents listing and [Save]. It never jumps to Name or File type or Automatically select or [Cancel]. It's as if there's a second set of tab fields and once you drop into the smaller set you can only get out by using the mouse.

EXPECTED RESULT
Tabbing between fields should consistently work. The tab order should in general be right-to-left top-to-bottom, and you shouldn't get locked out of certain fields. Maybe the Folder path field is special because it can be "dirty" and not match the directory contents listing, but the behavior us confusing.

SOFTWARE/OS VERSIONS 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.15.5
KDE Frameworks Version: 5.59.0 (using xcb/X11)
Qt Version: 5.12.4

ADDITIONAL INFORMATION

I noticed this bug in Spectacle, but Kwrite seems to have the same bug, so I assume the bug is in the framework.

Workaround: press <Alt> to reveal the keyboard shortcut 'N' for Name.

Maybe the setFocusPolicy fix for inconsistent tabbing Bug 398275 in DrKonqi, and related commit c695aa5a21a7 , applies?
Comment 1 Nate Graham 2025-01-30 17:41:20 UTC
Let's use this to track the focus not moving in a logical way.

The bug about focus getting stuck can be tracked with Bug 466206.
Comment 2 Nate Graham 2025-01-30 17:41:48 UTC
Er, no, sorry, it's tracked with Bug 466209.
Comment 3 Nate Graham 2025-01-30 17:42:47 UTC
*** Bug 452993 has been marked as a duplicate of this bug. ***
Comment 4 Marco Martin 2025-02-04 13:52:07 UTC
Git commit 4a77d4d5630950d5662befd936455c6b13285d99 by Marco Martin.
Committed on 04/02/2025 at 13:51.
Pushed by mart into branch 'master'.

A way to insert KUrlNavigator pieces in a deterministic place in the focus chain

QWidget::setTabOrder won't work correctly with KUrlNavigator, as by
itself it won't accept focus, but will contain child widgets on which
setTabOrder will be set by itself, altering the tab order that might
have been set by any parent widget
Related: bug 466209
FIXED-IN: 6.11

M  +39   -7    src/filewidgets/kfilewidget.cpp
M  +10   -1    src/filewidgets/kurlnavigator.cpp
M  +10   -0    src/filewidgets/kurlnavigator.h

https://invent.kde.org/frameworks/kio/-/commit/4a77d4d5630950d5662befd936455c6b13285d99