Skip to content

Restore menu item focus for accessibility, fix DropdownMenu#293

Merged
john-preston merged 1 commit intodesktop-app:masterfrom
rezabakhshilaktasaraei:fix/dropdown-menu-focus-restore
Mar 12, 2026
Merged

Restore menu item focus for accessibility, fix DropdownMenu#293
john-preston merged 1 commit intodesktop-app:masterfrom
rezabakhshilaktasaraei:fix/dropdown-menu-focus-restore

Conversation

@rezabakhshilaktasaraei
Copy link
Contributor

@rezabakhshilaktasaraei rezabakhshilaktasaraei commented Mar 11, 2026

Summary

  • Re-enables setFocus() in ItemBase::setSelected() for screen reader support (reverted in 6d3541f)
  • Saves the previously focused widget when DropdownMenu shows, restores it when the menu hides
  • Prevents DropdownMenu from stealing focus permanently from the input field

Problem

Setting focus on menu items is needed for screen readers (NVDA/JAWS) to announce selected items. However, this broke DropdownMenu (in-window menus like the attach menu): focus was grabbed from the input field, and when the menu closed, focus jumped to the first focusable widget (chats search) instead of returning to the original widget.

Solution

Save/restore focus in DropdownMenu:

  • On show: save QApplication::focusWidget() (only if not already a child of the menu)
  • On hide: restore focus to the saved widget

This keeps accessibility working (menu items get focus for screen readers) while ensuring DropdownMenu doesn't permanently steal focus.

Re-enable setFocus() in menu item selection for screen reader
support. Save and restore the previously focused widget in
DropdownMenu so that focus returns correctly when the menu hides.
@rezabakhshilaktasaraei rezabakhshilaktasaraei force-pushed the fix/dropdown-menu-focus-restore branch from 66c8d33 to 99aaa5f Compare March 11, 2026 07:44
@john-preston john-preston merged commit c4bc711 into desktop-app:master Mar 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants