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

Give ui.browseableMessage the ability to show copy and close buttons after the message, and add buttons to some instances (2nd try) #17018

Merged
merged 15 commits into from
Aug 29, 2024

Conversation

XLTechie
Copy link
Collaborator

@XLTechie XLTechie commented Aug 18, 2024

Link to issue number:

Fixes #14641
Addresses #16995
Addresses #16996

Summary of the issue:

In #14641 @Qchristensen reported that some users are confused by browseableMessages, and their lack of definite closure mechanisms.
During the conversation, it was pointed out that in some cases, a user might also desire a copy button.
During work on the PR (originally #16369), it was requested that the copy button be given an accelerator key.

Description of user facing changes

Added copy and close buttons to some browseableMessages, and the capability to add them to others.

Description of development approach

  • Thanks to @michaelDCurran's change in ui.browseableMessage--namely adding a Scripting.Dictionary to carry arbitrary query-string-equivalent style parameters to the mshtml instance behind browseableMessage, it is now possible to pass in values for two new buttons, and various translatable messages, without any contortions.
  • Tried different methods in the JS and CSS of message.html, and eventually settled on one which displayed the two buttons side-by-side, under a separator. If neither button's label is supplied, the div containing the HR and buttons remains hidden.
  • The "Copy" button can be activated with Ctrl+Shift+C, and the "Close" button by Escape. ctrl+shift+c is indicated to the user via an accessibility label.
  • Fixed up some docstring parameter listings to match modern format.
  • Per the issue, modified the Report Link Destination message, to have both a copy button and a close button.
  • Per the issue, added buttons to the Report Character Information message.
  • Per request in PR comments, used a live region to present a "Copy complete" or "copy failed" message to the user. This message remains on screen for five seconds.
  • The AI suggested covering for more failures in the initialization and configuration of MSHTML. I used its suggested exception checking, but added a private function to display an error message to the user when one of the components fail, so at least some kind of user notice can be given. I based it on the already extant private function for messaging the user if a browseableMessage is called on a secure screen.
  • Both of the warning functions for browseableMessage unavailable situations, are now self-contained, with respect to wx.
  • Added an immediate return if the MSHTML window is opened without providing the dialog arguments (i.e. the message and title, at least). That situation should never actually occur, but in the unlikely event that a failure passes the error checking we have in browseableMessage, this will return immediately, instead of stranding the user in a blank window with no obvious close mechanism.

Testing strategy:

  • Tested using the report link destination window, that the basic functionality worked as expected.
  • Tested that copying using the copy button, correctly formatted the clipboard result. That is so far only possible when using .innerHTML.
  • Tested that presentation with screen layout off, does not include extra blank lines (per In ui.browseableMessage, every other line is empty #16995). This can apparently only be achieved, by passing the message to the div using .innerHTML.
  • Tested that the component failure error dialog works correctly, by causing a component to fail.
  • Tested that the Can't run on UAC, etc. screens warning works correctly after changes.

Known issues with pull request:

  • Ctrl+Shift+C is not an ideal key to activate the copy button, and it can not be changed by translators.
  • The shortcut Ctrl+Shift+C is reported, no matter the state of "Report object shortcut keys" in "Object Presentation" settings. This is, AFAIK, unavoidable.
  • In addition to the others, it was requested that the OCR results window provide a close button. This is more difficult, and I'd rather leave it to a separate PR in case it is not desired after all.
  • Security of text only messages, is currently only provided by Python's html.escape(). I don't believe security is degraded by this PR, but it is not improved, either.

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

Summary by CodeRabbit

  • New Features

    • Added "Copy" and customizable "Close" buttons to message dialogs, improving usability.
    • Enhanced key handling for closing windows and copying text using keyboard shortcuts.
    • Introduced user notifications for copy operation success or failure, providing immediate feedback.
  • Bug Fixes

    • Improved error handling and user notifications for messaging components, ensuring reliability.
  • Documentation

    • Updated user documentation to reflect new interactive elements and usability improvements.

Luke Davis and others added 3 commits August 16, 2024 06:07
…instances.

* Report link destination, Speak selection command, & character formatting browseableMessages given close and copy buttons.
* Added a new browsable message component failure messaging function.
* Used a live region to alert users about the status of the copy operation.
* Added some further error handling, as proposed by the AI.
* Change onkeypress to onkeydown, in order to pick up modifier keys in message.html.
* Used Ctrl+Shift+C for the copy button accelerator key, because Alt+C makes a Windows error ding.
* Switch to innerText from innerHTML where possible.
* Remove invalid language attribute on body element in message.html per review.
* Solve for MSHTML bug in the use of aria-labelledby.
* Close the MSHTML Window if args wasn't provided for some reason.
@XLTechie XLTechie changed the title Fix14641again 2nd try: Give ui.browseableMessage the ability to show copy and close buttons after the message, and add buttons to some instances Aug 18, 2024
@XLTechie XLTechie changed the title 2nd try: Give ui.browseableMessage the ability to show copy and close buttons after the message, and add buttons to some instances Give ui.browseableMessage the ability to show copy and close buttons after the message, and add buttons to some instances (2nd try) Aug 18, 2024
@seanbudd seanbudd added the merge-early Merge Early in a developer cycle label Aug 19, 2024
@seanbudd seanbudd added this to the 2025.1 milestone Aug 19, 2024
@XLTechie XLTechie marked this pull request as ready for review August 19, 2024 05:10
@XLTechie XLTechie requested a review from a team as a code owner August 19, 2024 05:10
Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Walkthrough

The recent changes enhance the user interface by adding interactive "Close" and "Copy" buttons to various dialog boxes, improving accessibility and user experience. Additionally, new key handling functionality allows users to easily close dialogs and copy text, while updated messaging functions provide clearer user notifications. These improvements aim to make the application more intuitive, particularly for users relying on assistive technologies.

Changes

Files Change Summary
source/globalCommands.py Updated function calls to ui.browseableMessage with new copyButton and closeButton parameters for improved interactivity in user messages.
source/message.html Introduced handleKeyPress for key interactions; added notifications for copy actions and improved event handling for key presses.
source/ui.py Enhanced warning functions to handle title parameters more flexibly and improved error handling in browseableMessage to provide better feedback on issues.
user_docs/en/changes.md Documented improvements to dialog boxes, detailing the addition of "Close" and "Copy" buttons and updates to ui.browseableMessage function parameters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dialog
    participant UI

    User->>Dialog: Open Dialog
    Dialog->>UI: Display message with Close and Copy buttons
    User->>Dialog: Press Escape
    Dialog->>UI: Close dialog
    User->>Dialog: Click Copy button
    Dialog->>UI: Copy content to clipboard
    UI->>User: Show copy status message
Loading

Assessment against linked issues

Objective Addressed Explanation
Append "press escape to close" information to dialogs (##14641)
Enhance interactivity with Close and Copy buttons
Improve feedback mechanisms in user interface

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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: 3

source/message.html Outdated Show resolved Hide resolved
source/message.html Outdated Show resolved Hide resolved
source/ui.py Outdated Show resolved Hide resolved
@XLTechie XLTechie marked this pull request as draft August 19, 2024 05:49
@XLTechie XLTechie marked this pull request as ready for review August 19, 2024 06:41
@XLTechie
Copy link
Collaborator Author

@CyrilleB79 Here is a new version of this PR, which should address most of your concerns.

@seanbudd
Copy link
Member

@XLTechie - can you explain how #16995 was addressed in this PR? what changed in the dev approach?

@XLTechie
Copy link
Collaborator Author

@seanbudd I've added a detailed answer to the description.

@CyrilleB79
Copy link
Collaborator

All seems nice, either with or without screen layout.

Only one remaining point:
Using ui.browseableMessage("Hello world", "Trial"), there are no buttons as expected. Though, if I press control+shift+c, nothing is reported (no "Text copied" message), but the text is in the clipboard.
IMO the copy shortcut should be disabled when the button is not present.

Also another point but it's not worth blocking the PR for this. The shortcut control+shift+c is reported, no matter the state of "Report object shortcut keys" in "Object Presentation" settings. Though, it's probably not possible to do anything to honour this setting, and this detail is really not significant at all. Just mentioning here for awareness and maybe to add it in known issues section of the PR.

@XLTechie
Copy link
Collaborator Author

@CyrilleB79 Thank you for catching that oversight. An easy fix, which should be in the next build.
I will add a note to the PR about the inability to keep the accelerator from being mentioned.

@XLTechie
Copy link
Collaborator Author

@seanbudd Can you say why this is milestoned for 2025.1 instead of 2024.4? I don't care particularly, but I had intended to work on the NH3 integration after this was merged, and before 2025.1.
I can still work on it before that, but am curious.

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: 1

source/ui.py Show resolved Hide resolved
@AppVeyorBot
Copy link

See test results for failed build of commit 3dc5643057

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Aug 27, 2024
@seanbudd
Copy link
Member

@XLTechie - we try not to introduce new/risky features in the weeks before the first beta, it was unlikely that this would be merged before the first beta

@XLTechie
Copy link
Collaborator Author

@seanbudd Updated this to master. Note that the "Changes" section was missing from the changelog, and I have had to add it in this.

source/ui.py Outdated Show resolved Hide resolved
@seanbudd seanbudd merged commit 811df33 into nvaccess:master Aug 29, 2024
2 checks passed
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. merge-early Merge Early in a developer cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report "Press escape to close" on NVDA dialogs which the user needs to press escape to close
4 participants