Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): fix always ignoring click events
Browse files Browse the repository at this point in the history
Closes #6482
  • Loading branch information
epelc authored and ThomasBurleson committed Apr 1, 2016
1 parent 9624dac commit c998c49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function MdTab () {
scope.select = scope.select || angular.noop;
scope.deselect = scope.deselect || angular.noop;

scope.$watch('active', function (active) { if (active) ctrl.select(data.getIndex()); });
scope.$watch('active', function (active) { if (active) ctrl.select(data.getIndex(), true); });
scope.$watch('disabled', function () { ctrl.refreshIndex(); });
scope.$watch(
function () {
Expand Down
9 changes: 5 additions & 4 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,16 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
}

/**
* Update the selected index and trigger a click event on the original `md-tab` element in order
* to fire user-added click events.
* Update the selected index. Triggers a click event on the original `md-tab` element in order
* to fire user-added click events if canSkipClick or `md-no-select-click` are false.
* @param index
* @param canSkipClick Optionally allow not firing the click event if `md-no-select-click` is also true.
*/
function select (index) {
function select (index, canSkipClick) {
if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index;
ctrl.lastClick = true;
// skip the click event if noSelectClick is enabled
if (ctrl.noSelectClick) return;
if (canSkipClick && ctrl.noSelectClick) return;
// nextTick is required to prevent errors in user-defined click events
$mdUtil.nextTick(function () {
ctrl.tabs[ index ].element.triggerHandler('click');
Expand Down

0 comments on commit c998c49

Please sign in to comment.