Skip to content

Improve focus handling and accessibility in Connect dialog - #3859

Merged
softins merged 6 commits into
jamulussoftware:mainfrom
softins:connectdlg-focus-server
Aug 6, 2026
Merged

softins merged 6 commits into
jamulussoftware:mainfrom
softins:connectdlg-focus-server

Conversation

@softins

@softins softins commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Short description of changes

Deselects any selected server in the server list when the Server Address combo box gains focus. This ensures that clicking
Connect when the Server Address has focus will connect to the expected server, even if a server had previously been
selected in the server list.

In addition, corrects the consuming of Tab and shift-Tab within the server list, improving keyboard navigation for accessibility.

CHANGELOG: Client: Improve server list navigation in Connect Dialog.

Context: Fixes an issue?

Fixes #3857

Does this change need documentation? What needs to be documented and how?

No

Status of this Pull Request

Ready to merge. Tested on Linux and Windows..

What is missing until this pull request can be merged?

Nothing

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@softins softins added the bug Something isn't working label Aug 3, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Aug 3, 2026
@softins softins added the backport_required A change to main that needs fix on an existing release. label Aug 3, 2026
@softins softins added this to the Release 4.0.0 milestone Aug 3, 2026
Comment thread src/connectdlg.cpp Resolved
@github-project-automation github-project-automation Bot moved this from Triage to Waiting externally in Tracking Aug 3, 2026
@pljones

pljones commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

OK, here's an alternative suggestion.

When the connect dialog opens or on change of current Directory through the drop down, set "default Server" to the Directory. (Hm. Not sure on this -- if there's anything in the Server text field, that should still take precedence at this point, I think.)
When a Server in the server list is selected, set "default Server" to the selected Server.
When focus lands on the Server text field and there's a value in it, set "default Server" to that value.

When "Connect" is clicked, connect to "default Server". (Maybe that's not the best name for it, actually.)

(All of those are standard events from the widgets.)

@softins

softins commented Aug 5, 2026 •

Copy link
Copy Markdown
Member Author

OK, here's an alternative suggestion.

Well, for what it's worth, I don't actually like this at all! Touché!

When the connect dialog opens or on change of current Directory through the drop down, set "default Server" to the Directory. (Hm. Not sure on this -- if there's anything in the Server text field, that should still take precedence at this point, I think.) When a Server in the server list is selected, set "default Server" to the selected Server. When focus lands on the Server text field and there's a value in it, set "default Server" to that value.

When "Connect" is clicked, connect to "default Server". (Maybe that's not the best name for it, actually.)

You probably mean "selectedServer" or "chosenServer", but I don't think this is the right approach anyway. It's certainly not DRY. We already have the information in the widgets.

Certainly, setting to the directory would be wrong if there is a value in the server address field. Many times I open the connect dialog, and immediately click Connect because the server I want is already in the server address field.

But to me it's still logical that if there is a selected item in the server list, clicking Connect should use it, even if the list doesn't have focus. Therefore we need a way to unselect it if the user wants to use a custom server address. That will have been exactly why Volker made the list item be deselected when any change was made to the server address field. I still maintain that it is logical actually to do that as soon as the server Address field gains focus, as that action indicates that server is the server of interest to the user, not the one that was selected in the list.

If your objection boils down to the fact that the selection in the list is forgotten when focussing on the server address field, this can be overcome by saving the identity of the selected item before clearing the selection. Then if and when the server list is again given focus, either by tabbing, or by clicking in an empty area of it (if it's not full), we see there is a saved QTreeWidgetItem* and make it the selection again.

I have added a commit which does exactly that, and have tested it. I really do hope that overcomes your objection.

@pljones

pljones commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Somehow, yes, that works better for me. I'm still not sure about what should happen on switching focus with tab.

I'd never really noticed the old behaviour -- I guess I'd not have a selected server list entry if I was entering text into the Server text box (Would editTextChanged trigger when the selection from the Server dropdown changed? Will FocusIn be triggered for that?)

@softins

softins commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Somehow, yes, that works better for me. I'm still not sure about what should happen on switching focus with tab.

Well at the moment, pressing tab while in a list of servers just moves to the next server in the list, and shift-tab moves to the previous server. Down-arrow and up-arrow to the same.

I think only the arrow keys should move up and down, and tab should move to the next widget (which is the Server Address box), without changing the selection.

I'm not sure how to fix that, so it would need investigation and a separate PR.

I'd never really noticed the old behaviour -- I guess I'd not have a selected server list entry if I was entering text into the Server text box

Yes, I think that's the case for most people, which would be why #3857 has only come to light now.

(Would editTextChanged trigger when the selection from the Server dropdown changed? Will FocusIn be triggered for that?)

I just checked that. In all versions up till now, editTextChanged was triggered when either the text in the box was edited or a new entry was selected from the dropdown. The attached slot cleared the selection in the server list.

In this PR, editTextChanged is no longer needed, since FocusIn is triggered as soon as the cursor keys or a mouse click selects the widget, whether that be to edit the text or to click on the drop-down arrow.

@softins
softins requested a review from dingodoppelt August 5, 2026 22:03
@dingodoppelt

Copy link
Copy Markdown
Member

I'm not sure how to fix that, so it would need investigation and a separate PR.

My suggested change fixes that.

@softins

softins commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I'm not sure how to fix that, so it would need investigation and a separate PR.

My suggested change fixes that.

I haven't seen your suggestion (can't find it on my phone), but it seems to be that lvwServers currently has tabKeyNavigation set to true, unusually, in the .ui file. I intend to try setting that back to the default false, but first I want to check history to see if there was a reason for changing it.

@dingodoppelt

Copy link
Copy Markdown
Member

I'm not sure how to fix that, so it would need investigation and a separate PR.

My suggested change fixes that.

I haven't seen your suggestion (can't find it on my phone), but it seems to be that lvwServers currently has tabKeyNavigation set to true, unusually, in the .ui file. I intend to try setting that back to the default false, but first I want to check history to see if there was a reason for changing it.

Tab key navigation was introduced in d3b9f90 for no apparent reason. Turning it off (in the .ui file this time) feels much more natural and along the lines of OnjLouis' comment.
One other thing: When tabbing into the combo box hitting enter doesn't immediately connect. The text is highlighted first and enter deselects it and a second enter connects to the server. I don't know how to fix that though.

@pljones

pljones commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Tab key navigation was introduced in d3b9f90 for no apparent reason.

The reason was so the list was keyboard navigable, I'd assume. However, the next commit says it's a "fix" -- but doesn't remove the problem:

fix for issue with selection change in server list be up/down arrow keys

One other thing: When tabbing into the combo box hitting enter doesn't immediately connect. The text is highlighted first and enter deselects it and a second enter connects to the server. I don't know how to fix that though.

Tab onto the Connect button and hit enter? Although I get the point: I don't understand why the first press of enter would deselect the text at all...

Tab and Shift+Tab were being consumed to move between tree items rather than moving focus through the dialog.
Arrow-key navigation within the tree remains unchanged.
This restores conventional keyboard navigation and improves accessibility.
@softins softins changed the title Improve focus handling in Connect dialog Improve focus handling and accessibility in Connect dialog Aug 6, 2026

@dingodoppelt dingodoppelt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, thank you very much :)

Comment thread src/connectdlg.cpp Resolved
Comment thread src/connectdlg.cpp Resolved
@github-project-automation github-project-automation Bot moved this from Waiting externally to Waiting on Team in Tracking Aug 6, 2026
@softins

softins commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I've added a commit to turn off tab-key navigation within the server list, and updated the PR description.

I had a conversation with ChatGPT about it, and its comments were:

The combination of evidence is persuasive:

  • it appeared in 2011 alongside an unrelated widget setting;
  • neither the commit nor later code explains why it was needed;
  • no accessibility work has depended on it;
  • disabling it preserves all the useful tree navigation;
  • it restores the expected Tab/Shift+Tab traversal;
  • and a blind user has independently described the existing behaviour as odd.

I would treat the original setting as most likely accidental, or at least as an obsolete choice whose downside is now clear.

Certainly in the version I built with this change:

  • Up/Down still moves between servers.
  • Home/End and Page Up/Page Down still behave sensibly.
  • Enter/Return still connects to the selected server.
  • Tab and Shift+Tab now move to the next/previous control in the dialog.

@softins

softins commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

One other thing: When tabbing into the combo box hitting enter doesn't immediately connect. The text is highlighted first and enter deselects it and a second enter connects to the server. I don't know how to fix that though.

That's odd. Just seen that comment, and yes, it does that for me too. I'll hold off on merging to investigate the reason for that first.

Suggested by ChatGPT review.
@softins
softins force-pushed the connectdlg-focus-server branch from 2aad8ce to cd2ef20 Compare August 6, 2026 20:23
@softins
softins force-pushed the connectdlg-focus-server branch from cd2ef20 to 756bde2 Compare August 6, 2026 20:25
@softins

softins commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

One other thing: When tabbing into the combo box hitting enter doesn't immediately connect. The text is highlighted first and enter deselects it and a second enter connects to the server. I don't know how to fix that though.

That's odd. Just seen that comment, and yes, it does that for me too. I'll hold off on merging to investigate the reason for that first.

I've added another signal-slot connection, suggested by ChatGPT, that appears to fix that. Please could you check again?

@softins
softins requested a review from dingodoppelt August 6, 2026 20:27

@dingodoppelt dingodoppelt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works nicely and feels complete to me

@softins
softins merged commit a24e09c into jamulussoftware:main Aug 6, 2026
@github-project-automation github-project-automation Bot moved this from Waiting on Team to Done in Tracking Aug 6, 2026
@softins
softins deleted the connectdlg-focus-server branch August 6, 2026 21:00
@pljones

pljones commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

OK, there's something on main that's not on release/3_12 that's causing the cherry-pick some problems - and it doesn't patch cleanly either:

--- src/connectdlg.h
+++ src/connectdlg.h
@@ -127,6 +127,9 @@ protected:
     void                   EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion );
     void                   UpdateDirectoryComboBox();

+    bool                   eventFilter ( QObject* obj, QEvent* event ) override;
+    CMappedTreeWidgetItem* savedServer;
+
     CClient*         pClient;
     CClientSettings* pSettings;

--- src/connectdlg.cpp
+++ src/connectdlg.cpp
@@ -78,6 +78,7 @@ bool CMappedTreeWidgetItem::operator<( const QTreeWidgetItem& other ) const

 CConnectDlg::CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent ) :
     CBaseDlg ( parent, Qt::Dialog ),
+    savedServer ( nullptr ),
     pClient ( pNCliP ),
     pSettings ( pNSetP ),
     strSelectedAddress ( "" ),

These both fail because pClient is in the context of the commit being picked.

cffbe2313 (Tony Mountifield    2026-05-30 10:31:42 +0100 133)     CClient*         pClient;
cffbe2313 (Tony Mountifield    2026-05-30 10:31:42 +0100   82)     pClient ( pNCliP ),
cffbe231 2026-06-06 Auto-enable IPv6 by default, unless disabled [Tony Mountifield]

Hm. Can I leave out pClient safely for this? I'm assuming so.


A single squashed commit would have been easier here, too.

@softins

softins commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

ok, I'd need to be at the computer to check, which I can do later. I'd be happy to make a PR on release/3_12 if that would help.

@pljones

pljones commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

ok, I'd need to be at the computer to check, which I can do later. I'd be happy to make a PR on release/3_12 if that would help.

If you're okay to do the PR, that would help, yes. Thanks.

I've been doing a branch off release/3_12 called r3_12-<original branch name> locally (in my jamulussoftware/jamulus repo worktree), doing the change on that branch (ideally, just git cherry-pick <commit>...) and smoke testing, then doing git merge --no-ff <the r3_12-...branch> to release/3_12, before pushing to the release branch.

@softins

softins commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

Hm. Can I leave out pClient safely for this? I'm assuming so.

Yes, I think so. IIRC it was added to get access to the IPv6 availability status, which in 3.12 is just the enable flag.

Working on the PR now.

@softins

softins commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

PR #3870 raised against release/3_12

pljones added a commit that referenced this pull request Aug 8, 2026
…-focus-server

Backport #3859: Improve focus handling and accessibility in Connect dialog
@pljones pljones modified the milestones: Release 4.0.0, Release 3.12.4 Aug 8, 2026
@pljones pljones removed the backport_required A change to main that needs fix on an existing release. label Aug 8, 2026
@pljones

pljones commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Backport merged to release/3_12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Connect button in connect dialogue doesn't connect to the expected server

3 participants