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

fix: copy issue details button on insecure origin target page #4170

Merged
merged 11 commits into from
May 12, 2021

Conversation

kennyzhen13
Copy link
Contributor

Details

This PR improves the behavior of the copy issue details button of the detail dialog when a user is using AI-Web on an insecure target page. There are two main changes:

  1. Upon failing to copy details due to insecure origin, the toast message now reads "Failed to copy failure details." as suggested: General error message for Copy failure details on non-HTTPS and non-localhost webpages #3803 (comment). Example screenshot is shown below:
    UpdatedToastMessage

  2. In addition to (1), a help message also appears under the row of buttons that reads "To copy failure details, first open the details page." Example screenshot with each button's respective help message visible is shown below:
    AllHelpMessagesVisible

Motivation

This address issue #3803

Context

When verifying the usability with screen reader software (Mac OSX VoiceOver), the help message is read aloud but the toast message is not. On subsequent clicks of the copy issue details button, the toast message is read aloud (since the help message stays visible after the first click). What should be the expected behavior?

Alternative approaches:

  • When all help messages are visible, they are not ordered the same respective to the layout of the buttons (ex. copy issue details button is second in line, but its help message is last). This is because the help messages are rendered in different files. I considered separating the help messages into their own components, but did not proceed to avoid changing files that were unrelated to this issue.

Pull request checklist

  • Addresses an existing issue: General error message for Copy failure details on non-HTTPS and non-localhost webpages #3803
  • Ran yarn fastpass
  • Added/updated relevant unit test(s) (and ran yarn test)
  • Verified code coverage for the changes made. Check coverage report at: <rootDir>/test-results/unit/coverage
  • PR title AND final merge commit title both start with a semantic tag (fix:, chore:, feat(feature-name):, refactor:). See CONTRIBUTING.md.
  • (UI changes only) Added screenshots/GIFs to description above
  • (UI changes only) Verified usability with NVDA/JAWS

@kennyzhen13 kennyzhen13 requested a review from a team as a code owner April 29, 2021 05:32
@ghost
Copy link

ghost commented Apr 29, 2021

CLA assistant check
All CLA requirements met.

hasSecureTargetPage: this.props.dialogHandler.isTargetPageOriginSecure(),
shouldShowInsecureOriginPageMessage: () =>
this.props.dialogHandler.shouldShowInsecureOriginPageMessage(this),
onClickCopyIssueDetailsButtonHelpMessage: this.onClickCopyIssueDetailsButtonHelpMessage,
Copy link
Contributor

Choose a reason for hiding this comment

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

I felt a little confused by the name onClickCopyIssueDetailsButtonHelpMessage when I read it initially; based on the name, I expected it to be something that would get called when the button's help message was clicked.

Perhaps it would be more clear to just keep the single existing onClickCopyIssueDetailsButton prop, and give it handler which does both the existing this.props.deps.targetPageActionMessageCreator.copyIssueDetailsClicked() and the new setState({ showInsecureOriginPageMessage: ... }) operations? I think this would be more consistent with how DetailsDialogHandler.inspectButtonClickHandler works.

@@ -167,6 +174,10 @@ export class DetailsDialog extends React.Component<DetailsDialogProps, DetailsDi
shouldShowInspectButtonMessage: () =>
this.props.dialogHandler.shouldShowInspectButtonMessage(this),
userConfigurationStoreData: this.state.userConfigurationStoreData,
hasSecureTargetPage: this.props.dialogHandler.isTargetPageOriginSecure(),
shouldShowInsecureOriginPageMessage: () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

You've done a good job of using a consistent pattern with what the existing shouldShowInspectButtonMessage is doing, but unfortunately I think the existing code has set a bad example for you to follow. I think it would be better to pass this.state.showInsecureOriginPageMessage as a value here, rather than passing a prop which is a function that returns that value.

React chooses whether to re-render a child component as part of re-rendering a parent component based on whether the props passed to the child have changed. However, by passing a prop of the form () => something, React is going to see the prop changing with every parent render (since the parent is creating a new lambda function to pass on every render). That's not ideal; it would be better to pass the value from the state as the prop, so that React can detect whether the state value has changed from render-to-render, and can avoid re-rendering the child component unnecessarily if that value hasn't changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing this won't have a direct impact on its own without changing the existing issues in the similar props; if any single prop has this issue, the whole child component will have this issue. It's not necessary to fix the old code as part of this PR; it would probably be better to do that in its own separate PR. But as you've seen, it's really easy for new code in the future to copy from what old code is doing, so I think it would be nice to improve this for the new code even in the absence of fixing the old code.

Copy link
Contributor

@dbjorge dbjorge left a comment

Choose a reason for hiding this comment

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

Thanks very much for the contribution! I've left a few comments inline, but this looks great overall, especially the thorough unit test updates.

@kennyzhen13
Copy link
Contributor Author

@dbjorge thank you for the review! I will address the comments. What is your recommendation regarding the screen reader behavior with the toast message (described under Context in the PR description)?

@dbjorge
Copy link
Contributor

dbjorge commented May 5, 2021

@kennyzhen13 I definitely think we should improve the screen reader behavior, but I lean towards creating a separate issue and PR for it; it sounds like the issues are mostly-present already in the similar messages, we'll want to fix them holistically and probably need some design review work to figure out the right flow. Would you mind opening a new issue to track it so we can make sure it doesn't get lost?

@kennyzhen13
Copy link
Contributor Author

@dbjorge I have addressed the comments in my newest commit. I have also created a new bug #4211 for the screen reader behavior as discussed. Looking forward to your input.

@dbjorge
Copy link
Contributor

dbjorge commented May 10, 2021

Thanks for the update! Code-wise, this looks good to me.

User experience-wise, though, I think we'll probably want slightly different wording than "first open the details page" - the term "details page" is what we call the combined fastpass/assessment page internally, but we don't use that term in anything user-facing. @ferBonnin / @juchampa , do you have specific wording you'd like to see for the error text here to indicate that the user needs to open the FastPass/Assessment page?

@ferBonnin
Copy link
Contributor

User experience-wise, though, I think we'll probably want slightly different wording than "first open the details page" - the term "details page" is what we call the combined fastpass/assessment page internally, but we don't use that term in anything user-facing. @ferBonnin / @juchampa , do you have specific wording you'd like to see for the error text here to indicate that the user needs to open the FastPass/Assessment page?

In our documentation, we simply refer to the details view as the "Accessibility Insights for Web page" we could try this?

@kennyzhen13
Copy link
Contributor Author

In our documentation, we simply refer to the details view as the "Accessibility Insights for Web page" we could try this?

I can go ahead and change the text to "To copy failure details, first open the Accessibility Insights for Web page."

Copy link
Contributor

@dbjorge dbjorge left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for the contribution!

@dbjorge dbjorge merged commit c4b66bf into microsoft:main May 12, 2021
jalkire pushed a commit that referenced this pull request May 19, 2021
…ils button from an insecure target page (#4234)

#### Details
This PR is a continuation of PR #4170 and addresses the bug described in #4211. 

Previously, from an insecure target page, if a user clicks the "Copy failure details" button then two messages will render: 
1. help message under the button that reads "To copy failure details, first open the Accessibility Insights for Web page." 
2. toast pop-up reading "Failed to copy failure details." 

Now, this PR removes the aforementioned toast pop-up. Example screenshot is shown below.
![helpMessage](https://user-images.githubusercontent.com/2243970/118338631-7937e880-b4cb-11eb-87ea-f368bca41713.png "Help message visible from clicking 'Copy failure details.' Toast message does not appear anymore.")

<!-- Usually a sentence or two describing what the PR changes -->

##### Motivation
Addresses bug #4211 
<!-- This can be as simple as "addresses issue #123" -->

##### Context

<!-- Are there any parts that you've intentionally left out-of-scope for a later PR to handle? -->

<!-- Were there any alternative approaches you considered? What tradeoffs did you consider? -->

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox -->
- [x] Addresses an existing issue: #4211 
- [x] Ran `yarn fastpass`
- [x] Added/updated relevant unit test(s) (and ran `yarn test`)
- [x] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage`
- [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`.
- [x] (UI changes only) Added screenshots/GIFs to description above
- [x] (UI changes only) Verified usability with NVDA/JAWS
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.

3 participants