From bf1768e7521286c5a79de9cdbe63ce2054b86968 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Thu, 10 Dec 2015 22:47:17 -0800 Subject: [PATCH] fix(dropdown): do not close on right click - Do not close the dropdown on right click when open due to Firefox's behavior Closes #5052 Fixes #5051 --- src/dropdown/dropdown.js | 2 ++ src/dropdown/test/dropdown.spec.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 2ed4ae1bc4..1395963507 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -36,6 +36,8 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) if (evt && openScope.getAutoClose() === 'disabled') { return; } + if (evt && evt.which === 3) { return; } + var toggleElement = openScope.getToggleElement(); if (evt && toggleElement && toggleElement[0].contains(evt.target)) { return; diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js index a789534541..9d7977b902 100644 --- a/src/dropdown/test/dropdown.spec.js +++ b/src/dropdown/test/dropdown.spec.js @@ -79,6 +79,15 @@ describe('uib-dropdown', function() { expect(element).toHaveClass(dropdownConfig.openClass); }); + it('should not close on right click', function() { + clickDropdownToggle(); + element.find('ul a').trigger({ + type: 'mousedown', + which: 3 + }); + expect(element).toHaveClass(dropdownConfig.openClass); + }); + it('should close on $location change', function() { clickDropdownToggle(); expect(element).toHaveClass(dropdownConfig.openClass);