Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-order focus events for menuitemcheckbox and menuitemradio #16551

Merged
merged 13 commits into from
May 23, 2024

Conversation

SaschaCowley
Copy link
Member

@SaschaCowley SaschaCowley commented May 15, 2024

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:

  1. Detect objects with role IA2_ROLE_CHECK_MENU_ITEM or IA2.IA2_ROLE_RADIO_MENU_ITEM as well as oleacc.ROLE_SYSTEM_MENUITEM; and
  2. 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:

  • 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
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • 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.

Copy link
Contributor

coderabbitai bot commented May 15, 2024

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?

Share
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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to 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.yaml file 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.

@SaschaCowley
Copy link
Member Author

SaschaCowley commented May 15, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 15, 2024

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.

Copy link
Contributor

coderabbitai bot commented May 15, 2024

@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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 383b204 and 2752fa9.
Files selected for processing (2)
  • source/eventHandler.py (4 hunks)
  • user_docs/en/changes.md (1 hunks)
Additional Context Used
Ruff (1)
source/eventHandler.py (1)

278-278: f-string without any placeholders

Path-based Instructions (2)
source/eventHandler.py (1)

Pattern **/*: focus on code smells, logic errors, edge cases, missing test cases and serious issues.
Avoid minor issues such as linting, formatting and style issues.
_ is defined for gettext globally, errors for this being undefined can be ignored.
This project uses tabs instead of spaces, do not suggest usage of spaces over tabs.

user_docs/en/changes.md (1)

Pattern **/*: focus on code smells, logic errors, edge cases, missing test cases and serious issues.
Avoid minor issues such as linting, formatting and style issues.
_ is defined for gettext globally, errors for this being undefined can be ignored.
This project uses tabs instead of spaces, do not suggest usage of spaces over tabs.

Additional comments not posted (5)
source/eventHandler.py (5)

253-267: The changes to include IA2_ROLE_CHECK_MENU_ITEM and IA2_ROLE_RADIO_MENU_ITEM in the isMenuItemOfCurrentFocus method look good and align with the PR objectives.


321-323: The changes to allow focus redirection in the executeEvent function look good and align with the PR objectives.


Line range hint 34-34: The removal of logic for redirecting focus events in the queueEvent function looks good and aligns with the PR objectives.


Line range hint 13-13: The addition of the IAccessible2Lib import looks good and aligns with the PR objectives.


Line range hint 242-285: The updates to the FocusLossCancellableSpeechCommand class, including the isMenuItemOfCurrentFocus method, look good and align with the PR objectives.

@AppVeyorBot
Copy link

See test results for failed build of commit c8c7874981

@SaschaCowley SaschaCowley marked this pull request as ready for review May 15, 2024 02:46
@SaschaCowley SaschaCowley requested a review from a team as a code owner May 15, 2024 02:46
@SaschaCowley SaschaCowley requested a review from seanbudd May 15, 2024 02:46
@seanbudd seanbudd marked this pull request as draft May 17, 2024 02:18
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label May 20, 2024
@SaschaCowley SaschaCowley marked this pull request as ready for review May 22, 2024 05:40
return False

# Check that the old focus is a descendant of the new focus.
ancestor = self._obj.parent
while ancestor is not None:
if ancestor == lastFocus:
log.debugWarning(
log.debug(
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why the log level changed here?
Debug warning makes sense to me in this case, as it is a warning message.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log.debug(
log.debugWarning(

@seanbudd seanbudd merged commit 3390edd into nvaccess:master May 23, 2024
1 check passed
@SaschaCowley SaschaCowley deleted the announce_menuitem- branch August 22, 2024 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Menuitemradio or menuitemcheckbox is not announced, even though announcement is shown in NVDA Speech Viewer
3 participants