Skip to content

Commit

Permalink
refactor(tabs): preventDefault when anchor is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Feb 25, 2014
1 parent 3419e40 commit bdcd6bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions js/ext/angular/src/directive/ionicTabBar.js
Expand Up @@ -245,7 +245,7 @@ function($scope, $ionicViewService, $rootScope, $element) {
require: ['^ionTabs', '^ionTab'],
template:
'<a ng-class="{active: isTabActive(), \'has-badge\':badge}" ' +
'ng-click="selectTab()" class="tab-item">' +
'ng-click="selectTab($event)" class="tab-item">' +
'<span class="badge {{badgeStyle}}" ng-if="badge">{{badge}}</span>' +
'<i class="icon {{iconOn}}" ng-if="iconOn && isTabActive()"></i>' +
'<i class="icon {{iconOff}}" ng-if="iconOff && !isTabActive()"></i>' +
Expand Down Expand Up @@ -273,7 +273,8 @@ function($scope, $ionicViewService, $rootScope, $element) {
$scope.isTabActive = function() {
return tabsCtrl.selectedTab === tabCtrl.$scope;
};
$scope.selectTab = function() {
$scope.selectTab = function(e) {
e.preventDefault();
tabsCtrl.select(tabCtrl.$scope, true);
};
};
Expand Down
7 changes: 2 additions & 5 deletions test/e2e/viewState/test.js
@@ -1,8 +1,6 @@
describe('tabs test page', function() {
var P;
describe('viewState', function() {
beforeEach(function() {
browser.get('http://localhost:8080/test/e2e/viewState/test.html');
P = protractor.getInstance();
});

function navTitle() {
Expand All @@ -15,7 +13,6 @@ describe('tabs test page', function() {
}

it('navbar with multiple histories', function() {
browser.sleep(1000);
expect(navTitle().getText()).toBe('Sign-In');
expect(navButtons('back').getAttribute('class')).toContain('hide');
expect(navButtons('left').getText()).toEqual('Home');
Expand All @@ -40,7 +37,7 @@ describe('tabs test page', function() {
expect(navButtons('left').isPresent()).toBe(false);
expect(navButtons('right').isPresent()).toBe(false);

element(by.css('.tabs a.tab-item:nth-child(2)')).click();
element(by.css('.tabs a:nth-child(2)')).click();

expect(navTitle().getText()).toBe('Add Auto');
expect(navButtons('back').getAttribute('class')).toContain('hide');
Expand Down

0 comments on commit bdcd6bb

Please sign in to comment.