From 6bc38e593c8dbb7ea4cf97711bd4e0b2c4610d56 Mon Sep 17 00:00:00 2001 From: Ed Pelc Date: Mon, 28 Dec 2015 11:53:16 -0500 Subject: [PATCH] feat(tabs): allow disabling select click event by adding `md-no-select-click` attribute Closes #5351 #5930 --- src/components/tabs/js/tabsController.js | 3 +++ src/components/tabs/js/tabsDirective.js | 1 + 2 files changed, 4 insertions(+) diff --git a/src/components/tabs/js/tabsController.js b/src/components/tabs/js/tabsController.js index c577947cbdf..93c769e6b84 100644 --- a/src/components/tabs/js/tabsController.js +++ b/src/components/tabs/js/tabsController.js @@ -32,6 +32,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp defineBooleanAttribute('swipeContent'); defineBooleanAttribute('noDisconnect'); defineBooleanAttribute('autoselect'); + defineBooleanAttribute('noSelectClick'); defineBooleanAttribute('centerTabs', handleCenterTabs, false); defineBooleanAttribute('enableDisconnect'); @@ -291,6 +292,8 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp function select (index) { if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index; ctrl.lastClick = true; + // skip the click event if noSelectClick is enabled + if (ctrl.noSelectClick) return; // nextTick is required to prevent errors in user-defined click events $mdUtil.nextTick(function () { ctrl.tabs[ index ].element.triggerHandler('click'); diff --git a/src/components/tabs/js/tabsDirective.js b/src/components/tabs/js/tabsDirective.js index 0d21fa6ebf3..8e3fa6de57f 100644 --- a/src/components/tabs/js/tabsDirective.js +++ b/src/components/tabs/js/tabsDirective.js @@ -63,6 +63,7 @@ * @param {boolean=} md-swipe-content When enabled, swipe gestures will be enabled for the content area to jump between tabs * @param {boolean=} md-enable-disconnect When enabled, scopes will be disconnected for tabs that are not being displayed. This provides a performance boost, but may also cause unexpected issues and is not recommended for most users. * @param {boolean=} md-autoselect When present, any tabs added after the initial load will be automatically selected + * @param {boolean=} md-no-select-click When enabled, click events will not be fired when selecting tabs * * @usage *