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

Commit 9624dac

Browse files
epelcThomasBurleson
authored andcommitted
feat(tabs): allow disabling select click event by adding md-no-select-click attribute
Closes #5351 #5930
1 parent 2dcc90e commit 9624dac

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
3232
defineBooleanAttribute('swipeContent');
3333
defineBooleanAttribute('noDisconnect');
3434
defineBooleanAttribute('autoselect');
35+
defineBooleanAttribute('noSelectClick');
3536
defineBooleanAttribute('centerTabs', handleCenterTabs, false);
3637
defineBooleanAttribute('enableDisconnect');
3738

@@ -291,6 +292,8 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
291292
function select (index) {
292293
if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index;
293294
ctrl.lastClick = true;
295+
// skip the click event if noSelectClick is enabled
296+
if (ctrl.noSelectClick) return;
294297
// nextTick is required to prevent errors in user-defined click events
295298
$mdUtil.nextTick(function () {
296299
ctrl.tabs[ index ].element.triggerHandler('click');

src/components/tabs/js/tabsDirective.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
* @param {boolean=} md-swipe-content When enabled, swipe gestures will be enabled for the content area to jump between tabs
6464
* @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.
6565
* @param {boolean=} md-autoselect When present, any tabs added after the initial load will be automatically selected
66+
* @param {boolean=} md-no-select-click When enabled, click events will not be fired when selecting tabs
6667
*
6768
* @usage
6869
* <hljs lang="html">

0 commit comments

Comments
 (0)