Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8080adb

Browse files
yuheiychristopherthielen
authored andcommitted
fix: should not transition states when alt-clicked
In most browsers, clicking links with the Alt key has a special behavior, for example, Chromedownloads the target resource. As with other modifier keys, the router should stop the originalnavigation 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 |
1 parentc1d9551 commit8080adb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎src/directives/stateDirectives.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function clickHook(
9595
constbutton=e.which||e.button,
9696
target=getDef();
9797

98-
if(!(button>1||e.ctrlKey||e.metaKey||e.shiftKey||el.attr('target'))){
98+
if(!(button>1||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||el.attr('target'))){
9999
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
100100
consttransition=$timeout(function(){
101101
if(!el.attr('disabled')){

‎test/stateDirectivesSpec.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ describe('uiStateRef', function () {
232232
expect(obj($stateParams)).toEqual({});
233233
}));
234234

235+
it('should not transition states when alt-clicked',inject(function($state,$stateParams,$q){
236+
expect($state.$current.name).toEqual('top');
237+
expect(obj($stateParams)).toEqual({});
238+
239+
triggerClick(el,{altKey:true});
240+
timeoutFlush();
241+
$q.flush();
242+
243+
expect($state.current.name).toEqual('top');
244+
expect(obj($stateParams)).toEqual({});
245+
}));
246+
235247
it('should not transition states when middle-clicked',inject(function($state,$stateParams,$q){
236248
expect($state.$current.name).toEqual('top');
237249
expect(obj($stateParams)).toEqual({});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp