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

Commit

Permalink
feat(tabs): allow disabling select click event by adding `md-no-selec…
Browse files Browse the repository at this point in the history
…t-click` attribute

Closes #5351 #5930
  • Loading branch information
epelc authored and ThomasBurleson committed Mar 10, 2016
1 parent b6ecc31 commit 6bc38e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions src/components/tabs/js/tabsDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <hljs lang="html">
Expand Down

0 comments on commit 6bc38e5

Please sign in to comment.