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(router): If users are using the Alt key when clicking the router links, prioritize browser’s default behavior #38375

Closed
wants to merge 1 commit into from

Conversation

yuheiy
Copy link
Contributor

@yuheiy yuheiy commented Aug 7, 2020

When users click a link while holding the Alt key together, the browsers behave as follows.

Windows 10:

Browser Behavior
Chrome 84 Download the target resource
Firefox 79 Prevent navigation and therefore do nothing
Edge 84 Download the target resource
IE 11 No impact

macOS Catalina:

Browser Behavior
Chrome 84 Download the target resource
Firefox 79 Prevent navigation and therefore do nothing
Safari 13 Download the target resource

The Alt key has no impact on IE, but on most other browsers it does. As with other modifier keys, the router should stop the original navigation to avoid preventing the browser’s default behavior.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

This doesn't have an associate test for a few reasons:

  • No tests exist for the meta keys already, so adding one for this would take more effort
  • The test, if it were to be a unit test, wouldn't provide much value because it would have to pass in true specifically for the meta key and simply expect true back. This is akin to a change detector test
  • The ideal test would be a protractor test that verifies the behavior as described above -- i.e. that the Angular router does not trigger a navigation by clicking the routerLink, but instead the browser handles the click natively. This may be a little overkill to write for this simple change.

@pullapprove pullapprove bot requested a review from atscott August 7, 2020 11:08
@yuheiy yuheiy mentioned this pull request Aug 7, 2020
3 tasks
@sonukapoor sonukapoor added area: router router: directives RouterLink, RouterLinkActive, RouterOutlet etc. labels Aug 7, 2020
@ngbot ngbot bot added this to the needsTriage milestone Aug 7, 2020
@atscott
Copy link
Contributor

atscott commented Aug 7, 2020

Thanks @yuheiy, this is a really great summary of the behavior in each browser! Would you mind copying that summary in the PR description into the commit message? We try to make all the information immediately available there rather than having to try to find the associated PR after merging.

Can you also run yarn bazel run //packages/router:router_api.accept and add the new golden to the commit so the CI test passes?

@yuheiy
Copy link
Contributor Author

yuheiy commented Aug 7, 2020

I’ve updated the commit message and added the golden!

Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

reviewed-for: public-api
reviewed-for: fw-router

@pullapprove pullapprove bot requested a review from alxhub August 7, 2020 23:39
@atscott atscott added the target: patch This PR is targeted for the next patch release label Aug 7, 2020
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@jelbourn
Copy link
Member

@atscott @AndrewKushnir if we don't consider onClick to be public API here, could we mark it as @internal?

@atscott
Copy link
Contributor

atscott commented Aug 11, 2020

@atscott @AndrewKushnir if we don't consider onClick to be public API here, could we mark it as @internal?

Yea, we probably should mark it as internal.

@atscott
Copy link
Contributor

atscott commented Aug 13, 2020

@atscott @AndrewKushnir if we don't consider onClick to be public API here, could we mark it as @internal?

@jelbourn - I created a separate PR for this #38448

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

The addition of /** @nodoc */ in a recent commit has caused a conflict. Can you please rebase?

@petebacondarwin petebacondarwin added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 27, 2020
@yuheiy
Copy link
Contributor Author

yuheiy commented Aug 27, 2020

@petebacondarwin I rebased.

@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Aug 27, 2020
@ngbot
Copy link

ngbot bot commented Aug 27, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/circleci: test" is failing
    pending status "google3" is pending
    pending missing required status "ci/circleci: publish_snapshot"
    pending 3 pending code reviews

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@petebacondarwin
Copy link
Member

Caretaker - merge-assistance: the broken test is unrelated to this PR.

@petebacondarwin petebacondarwin removed the action: merge The PR is ready for merge by the caretaker label Aug 27, 2020
@petebacondarwin petebacondarwin added action: presubmit The PR is in need of a google3 presubmit and removed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Aug 27, 2020
@petebacondarwin
Copy link
Member

Sorry I was a bit to fast with the merge label. This change needs to go through presubmit against the internal Google repository.

@atscott
Copy link
Contributor

atscott commented Sep 2, 2020

presubmit

…links, prioritize browser’s default behavior

In most browsers, clicking links with the Alt key has a special behavior, for example, Chrome
downloads the target resource. As with other modifier keys, the router should stop the original
navigation to avoid preventing the browser’s default behavior.

When users click a link while holding the Alt key together, the browsers behave as follows.

Windows 10:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Edge 84    | Download the target resource                |
| IE 11      | No impact                                   |

macOS Catalina:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Safari 13  | Download the target resource                |
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: public-api

@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Sep 8, 2020
@atscott atscott closed this in c880e39 Sep 8, 2020
atscott pushed a commit that referenced this pull request Sep 8, 2020
…links, prioritize browser’s default behavior (#38375)

In most browsers, clicking links with the Alt key has a special behavior, for example, Chrome
downloads the target resource. As with other modifier keys, the router should stop the original
navigation to avoid preventing the browser’s default behavior.

When users click a link while holding the Alt key together, the browsers behave as follows.

Windows 10:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Edge 84    | Download the target resource                |
| IE 11      | No impact                                   |

macOS Catalina:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Safari 13  | Download the target resource                |

PR Close #38375
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router cla: yes router: directives RouterLink, RouterLinkActive, RouterOutlet etc. target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants