Skip to content

Commit 6d75fa0

Browse files
committed
Fix angular-ui#2962 by ensuring that parent ui-srefs don't overwrite the transitions started by ui-srefs on child elements
1 parent 4accdba commit 6d75fa0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ng1/directives/stateDirectives.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ function getTypeInfo(el: IAugmentedJQuery): TypeInfo {
5757
}
5858

5959
/** @hidden */
60+
let pendingTransition;
6061
function clickHook(el: IAugmentedJQuery, $state: StateService, $timeout: ITimeoutService, type: TypeInfo, current: Function) {
6162
return function(e: JQueryMouseEventObject) {
6263
var button = e.which || e.button, target = current();
6364

64-
if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
65+
if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target') || pendingTransition)) {
6566
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
66-
var transition = $timeout(function() {
67+
pendingTransition = $timeout(function() {
68+
pendingTransition = null;
6769
$state.go(target.state, target.params, target.options);
6870
});
6971
e.preventDefault();
@@ -72,7 +74,10 @@ function clickHook(el: IAugmentedJQuery, $state: StateService, $timeout: ITimeou
7274
var ignorePreventDefaultCount = type.isAnchor && !target.href ? 1: 0;
7375

7476
e.preventDefault = function() {
75-
if (ignorePreventDefaultCount-- <= 0) $timeout.cancel(transition);
77+
if (ignorePreventDefaultCount-- <= 0) {
78+
$timeout.cancel(pendingTransition);
79+
pendingTransition = null;
80+
}
7681
};
7782
}
7883
};

0 commit comments

Comments
 (0)