Commit a59b1cf5 authored by Robert Knight's avatar Robert Knight

Use <button> elements rather than <div>s for inner buttons in dropdown menu button

Using a <button> gives us keyboard accessibility and focus.

The downside is that additional styling is needed to suppress
default styling from the UA.

Card 89
parent 594f9341
// the primary action button for a form // the primary action button for a form
.dropdown-menu-btn { .dropdown-menu-btn {
$text-color: #f1f1f1;
$default-background-color: #626262; $default-background-color: #626262;
$hover-background-color: #3A3A3A; $hover-background-color: #3A3A3A;
$h-padding: 9px; $h-padding: 9px;
...@@ -12,7 +13,6 @@ ...@@ -12,7 +13,6 @@
border: 0px; border: 0px;
border-radius: $border-radius; border-radius: $border-radius;
color: #F1F1F1;
font-size: $body1-font-size; font-size: $body1-font-size;
font-weight: bold; font-weight: bold;
height: $height; height: $height;
...@@ -23,12 +23,19 @@ ...@@ -23,12 +23,19 @@
&__label { &__label {
// the label occupies the entire space of the button and // the label occupies the entire space of the button and
// shows a darker state on hover // shows a darker state on hover
width: 100%;
height: 100%;
color: $text-color;
background-color: transparent; background-color: transparent;
border-radius: $border-radius; border-radius: $border-radius;
border: none;
line-height: $height; line-height: $height;
padding-left: $h-padding; padding-left: $h-padding;
padding-right: $arrow-indicator-width + 8px; padding-right: $arrow-indicator-width + 8px;
height: 100%;
text-align: left;
vertical-align: middle; vertical-align: middle;
&:hover { &:hover {
...@@ -49,12 +56,25 @@ ...@@ -49,12 +56,25 @@
height: 100%; height: 100%;
width: $arrow-indicator-width; width: $arrow-indicator-width;
padding-left: 0px;
padding-right: $h-padding; padding-right: $h-padding;
margin-left: 8px; margin-left: 8px;
border: none;
background-color: transparent;
border-top-right-radius: $border-radius; border-top-right-radius: $border-radius;
border-bottom-right-radius: $border-radius; border-bottom-right-radius: $border-radius;
&:hover {
background-color: #3A3A3A;
}
&:hover &-separator {
// hide the 1px vertical separator when the dropdown arrow
// is hovered
background-color: transparent;
}
// 1px vertical separator between label and dropdown arrow // 1px vertical separator between label and dropdown arrow
&-separator { &-separator {
position: absolute; position: absolute;
...@@ -65,11 +85,13 @@ ...@@ -65,11 +85,13 @@
width: 1px; width: 1px;
height: 15px; height: 15px;
background-color: #818181; background-color: #818181;
} }
// the ▼ arrow which reveals the dropdown menu when clicked // the ▼ arrow which reveals the dropdown menu when clicked
&-indicator { &-indicator {
color: $text-color;
position: absolute; position: absolute;
left: 0px; left: 0px;
right: 0px; right: 0px;
...@@ -78,11 +100,6 @@ ...@@ -78,11 +100,6 @@
line-height: $height; line-height: $height;
text-align: center; text-align: center;
&:hover {
background-color: #3A3A3A;
border-top-right-radius: $border-radius;
border-bottom-right-radius: $border-radius;
}
& > div { & > div {
transform: scaleY(0.7); transform: scaleY(0.7);
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
in Firefox. See https://bugzilla.mozilla.org/show_bug.cgi?id=843003 in Firefox. See https://bugzilla.mozilla.org/show_bug.cgi?id=843003
!--> !-->
<div aria-role="button" tabindex="0" class="dropdown-menu-btn"> <div aria-role="button" tabindex="0" class="dropdown-menu-btn">
<div class="dropdown-menu-btn__label" ng-bind="label"></div> <button class="dropdown-menu-btn__label" ng-bind="label"></button>
<div <button
class="dropdown-menu-btn__dropdown-arrow" class="dropdown-menu-btn__dropdown-arrow"
title="{{dropdownMenuLabel}}" title="{{dropdownMenuLabel}}"
ng-click="vm.toggleDropdown($event)"> ng-click="vm.toggleDropdown($event)">
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
<div class="dropdown-menu-btn__dropdown-arrow-indicator"> <div class="dropdown-menu-btn__dropdown-arrow-indicator">
<div></div> <div></div>
</div> </div>
</div> </button>
</div> </div>
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