Skip to content

Commit ac54de5

Browse files
hellobriantw15egan
authored andcommitted
fix(number-input): use button for keyboard a11y (#275)
* fix(a11y): number-input uses button * fix(number-input): re-add styles for old HTML w/o buttons * fix(number-input): make focus-outline look better
1 parent 9b6eb15 commit ac54de5

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

src/components/number-input/_number-input.scss

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,32 @@
5454
align-items: center;
5555
}
5656

57-
.bx--number__controls .up-icon,
58-
.bx--number__controls .down-icon {
57+
.bx--number__control-btn {
58+
@include button-reset;
59+
position: relative;
60+
bottom: 0;
61+
width: rem(20px);
62+
height: rem(10px);
63+
64+
&:focus {
65+
@include focus-outline;
66+
}
67+
68+
&:hover {
69+
cursor: pointer;
70+
}
71+
72+
&:hover svg {
73+
fill: $brand-02;
74+
}
75+
}
76+
77+
.bx--number__controls svg {
5978
fill: $brand-01;
6079
width: rem(9px);
61-
height: rem(20px);
62-
position: relative;
80+
height: rem(9px);
6381

82+
// Hover styles for use with old HTML w/o button
6483
&:hover {
6584
cursor: pointer;
6685
fill: $brand-02;

src/components/number-input/number-input.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
<div data-numberinput class="bx--number">
44
<input id="number-input" type="number" min="0" max="100" value="1">
55
<div class="bx--number__controls">
6-
<svg class="up-icon" viewBox="0 -6 10 5" width="10" height="5" fill-rule="evenodd">
7-
<path d="M10 5L5 0 0 5z"></path>
8-
</svg>
9-
<svg class="down-icon" viewBox="0 6 10 5" width="10" height="5" fill-rule="evenodd">
10-
<path d="M10 0L5 5 0 0z"></path>
11-
</svg>
6+
<button class="bx--number__control-btn up-icon">
7+
<svg viewBox="0 2 10 5" width="10" height="5" fill-rule="evenodd">
8+
<path d="M10 5L5 0 0 5z"></path>
9+
</svg>
10+
</button>
11+
<button class="bx--number__control-btn down-icon">
12+
<svg viewBox="0 2 10 5" width="10" height="5" fill-rule="evenodd">
13+
<path d="M10 0L5 5 0 0z"></path>
14+
</svg>
15+
</button>
1216
</div>
1317
</div>
1418
</div>

0 commit comments

Comments
 (0)