Re-order focus events for menuitemcheckbox and menuitemradio
Link to issue number:
Fixes #14550
Summary of the issue:
NVDA does not correctly announce checkbox or radio button menuitems when first entering submenues in Firefox or Chrome, as its announcement of the menuitem is disrupted by its announcement of the containing menu or grouping.
Description of user facing changes
Checkbox and radio button menuitems are correctly read in Chrome and Firefox.
Description of development approach
Updated FocusLossCancellableSpeechCommand.isMenuItemOfCurrentFocus to:
- Detect objects with role
IA2_ROLE_CHECK_MENU_ITEMorIA2.IA2_ROLE_RADIO_MENU_ITEMas well asoleacc.ROLE_SYSTEM_MENUITEM; and - Traverse up the old focus's ancestors to find the ancestor menu, instead of assuming that it will be its parent, to support grouped menuitems.
Testing strategy:
Manual testing in Chrome and Firefox, using the APG editor menubar example.
Known issues with pull request:
None.
Code Review Checklist:
- [x] Documentation:
- Change log entry
- User Documentation
- Developer / Technical Documentation
- Context sensitive help for GUI changes
- [ ] Testing:
- Unit tests
- System (end to end) tests
- Manual testing
- [x] UX of all users considered:
- Speech
- Braille
- Low Vision
- Different web browsers
- Localization in other languages / culture than English
- [x] API is compatible with existing add-ons.
- [x] Security precautions taken.
Summary by CodeRabbit
-
Bug Fixes
- Removed focus event redirection logic to fix issues with menu item announcements in NVDA.
-
Refactor
- Updated comments, imports, and logic in various functions related to focus conditions and relationships.
-
New Features
- Improved menu item announcements in NVDA for radio and checkbox items in Google Chrome and Mozilla Firefox.
Walkthrough
The recent changes focus on improving NVDA's handling of radio and checkbox menu items in web browsers. These updates in the eventHandler.py file enhance focus event management and accessibility checks, ensuring proper announcement of menu items, especially in Google Chrome and Mozilla Firefox. The user documentation has been updated to reflect these changes, emphasizing the correct announcement of radio and checkbox menu items.
Changes
| Files | Change Summary |
|---|---|
| source/eventHandler.py | Removed focus redirection logic in queueEvent, updated comments, added IAccessible2Lib imports, revised isMenuItemOfCurrentFocus for focus conditions, and modified executeEvent for focus redirection. |
| user_docs/en/changes.md | Documented the new functionality for announcing radio and checkbox menu items correctly in browsers. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Ensure NVDA announces radio and checkbox menu items correctly when entering submenus in Chrome and Firefox (#14550) | ✅ | |
| Validate the NVDA Speech Viewer shows the correct announcement for menuitemradio or menuitemcheckbox (#14550) | ✅ |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>. -
Generate unit testing code for this file. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table. -
@coderabbitai show all the console.log statements in this repository. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@coderabbitai review
Actions Performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@SaschaCowley, I have reviewed the implementation of the isMenuItemOfCurrentFocus method in source/eventHandler.py. The method correctly includes checks for IA2_ROLE_CHECK_MENU_ITEM and IA2.IA2_ROLE_RADIO_MENU_ITEM and traverses up the ancestors to find the ancestor menu, aligning with the objectives stated in the PR.
The changes appear to be well-implemented and should address the issue of NVDA not correctly announcing checkbox or radio button menuitems when first entering submenus in Firefox or Chrome.
If there are any specific aspects you would like me to focus on or if you have any questions, please let me know!
Analysis chain
@SaschaCowley, I will review the changes made in this pull request to ensure they align with the stated objectives and provide feedback accordingly. Let's start by examining the modifications in the FocusLossCancellableSpeechCommand.isMenuItemOfCurrentFocus method.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for the implementation of the `FocusLossCancellableSpeechCommand.isMenuItemOfCurrentFocus` method to review the changes.
ast-grep --lang python --pattern $'class FocusLossCancellableSpeechCommand {
$$$
def isMenuItemOfCurrentFocus($_) {
$$$
}
$$$
}'
Length of output: 488
Script:
#!/bin/bash
# Search for the definition of the `isMenuItemOfCurrentFocus` method in the `FocusLossCancellableSpeechCommand` class using ripgrep.
rg 'def isMenuItemOfCurrentFocus' -A 10
Length of output: 1007
Script:
#!/bin/bash
# Extract the full implementation of the `isMenuItemOfCurrentFocus` method from the `source/eventHandler.py` file.
ast-grep --lang python --pattern $'def isMenuItemOfCurrentFocus($_) {
$$$
}' source/eventHandler.py
Length of output: 567
Script:
#!/bin/bash
# Extract a larger portion of the `source/eventHandler.py` file around the `isMenuItemOfCurrentFocus` method to capture its full implementation.
rg 'def isMenuItemOfCurrentFocus' -A 50 source/eventHandler.py
Length of output: 2162
Actions Performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
- FAIL: Lint check. See test results for more information.
- Build (for testing PR): https://ci.appveyor.com/api/buildjobs/1el59hocly7ivps3/artifacts/output/nvda_snapshot_pr16551-31928,c8c78749.exe
- PASS: Translation comments check.
- CI timing (mins): INIT 0.0, INSTALL_START 1.0, INSTALL_END 0.9, BUILD_START 0.0, BUILD_END 27.2, TESTSETUP_START 0.0, TESTSETUP_END 0.4, TEST_START 0.0, TEST_END 2.1, FINISH_END 0.2
- PASS: System tests (tags: installer NVDA).
- PASS: Unit tests.
See test results for failed build of commit c8c7874981