Commit acd8374e authored by Robert Knight's avatar Robert Knight

Fix an issue where clicking the dropdown arrow in Chrome saved changes

In Chrome, clicks on elements inside a disabled <button>
will not invoke the <button>'s "click" event listeners
but they will propagate through the button and invoke parent
element's click handlers. In Firefox however, the click
event is not propagated.

The fix here is to install the click handler for the main
part of a dropdown button on the <button> itself, rather than
the container <div> which holds the main button and
the dropdown arrow.

Card 89
parent e3af076b
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// @ngInject // @ngInject
function DropdownMenuBtnController($scope, $timeout) { function DropdownMenuBtnController($scope, $timeout) {
this.onClick = function($event) {
$scope.onClick();
};
this.toggleDropdown = function($event) { this.toggleDropdown = function($event) {
$event.stopPropagation(); $event.stopPropagation();
$timeout(function () { $timeout(function () {
...@@ -19,6 +23,7 @@ module.exports = function () { ...@@ -19,6 +23,7 @@ module.exports = function () {
isDisabled: '=', isDisabled: '=',
label: '=', label: '=',
dropdownMenuLabel: '@', dropdownMenuLabel: '@',
onClick: '&',
onToggleDropdown: '&', onToggleDropdown: '&',
}, },
templateUrl: 'dropdown_menu_btn.html' templateUrl: 'dropdown_menu_btn.html'
......
<div class="dropdown-menu-btn"> <div class="dropdown-menu-btn">
<button class="dropdown-menu-btn__label" ng-bind="label" ng-disabled="isDisabled"></button> <button
class="dropdown-menu-btn__label"
ng-bind="label"
ng-click="vm.onClick($event)"
ng-disabled="isDisabled">
</button>
<button <button
class="dropdown-menu-btn__dropdown-arrow" class="dropdown-menu-btn__dropdown-arrow"
title="{{dropdownMenuLabel}}" title="{{dropdownMenuLabel}}"
......
<div dropdown="" class="publish-annotation-btn__btn" is-open="vm.showDropdown" keyboard-nav> <div dropdown="" class="publish-annotation-btn__btn" is-open="vm.showDropdown" keyboard-nav>
<dropdown-menu-btn <dropdown-menu-btn
label="'Post to ' + vm.publishDestination" label="'Post to ' + vm.publishDestination"
ng-click="vm.save()" on-click="vm.save()"
on-toggle-dropdown="vm.showDropdown = !vm.showDropdown" on-toggle-dropdown="vm.showDropdown = !vm.showDropdown"
title="Publish this annotation to {{vm.publishDestination}}" title="Publish this annotation to {{vm.publishDestination}}"
dropdown-menu-label="Change annotation sharing setting" dropdown-menu-label="Change annotation sharing setting"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment