Skip to content

Commit e7b6f72

Browse files
author
Chris Johnson
committed
PR review fixes
1 parent cb29145 commit e7b6f72

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

lib/modules/interaction/_inputs.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@
88

99
$input-height: rus(2);
1010

11-
input {
11+
@mixin input-padding() {
1212
@include padding($base: 1, $left: true, $right: true);
13+
}
14+
15+
input {
16+
@include input-padding;
1317
border: 1px solid map.get($base-color, "border");
1418
border-radius: $border-radius;
1519
height: $input-height;
1620
}
1721

1822
.Select {
19-
background-color: map.get($base-color, "body");
2023
border: 1px solid map.get($base-color, "border");
2124
border-radius: $border-radius;
2225
min-height: $input-height;
2326

2427
&__option {
2528
@include flex($align: center);
26-
@include padding($base: 1, $left: true, $right: true);
29+
@include input-padding;
2730
height: $input-height;
2831

2932
&:hover,

lib/modules/typography/_constants.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* stylelint-disable comment-empty-line-before */
21
@use "../constants/breakpoints.scss" as *;
32

43
$base-font-size: 16px; // DOCS: basefontsize

site/components/base-select.vue

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const handleInputFocus = (e: KeyboardEvent): void => {
6161
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
6262
e.preventDefault();
6363
64-
clearSubstringSearchMatches();
6564
focusRefSearchInput();
6665
}
6766
};
@@ -80,10 +79,10 @@ const handleSelectKeydownTab = (shiftKey = false) => {
8079
return;
8180
}
8281
83-
const activeSelectOption = document.activeElement;
84-
const activeSelectOptionIndex = activeSelectOption && activeSelectOption.classList.contains('BaseSelect__option')
82+
const activeElement = document.activeElement;
83+
const activeElementIndex = activeElement && activeElement.classList.contains('BaseSelect__option')
8584
? refSelectOptions.value.findIndex((option: HTMLLIElement) => {
86-
return option.id === activeSelectOption.id;
85+
return option.id === activeElement.id;
8786
})
8887
: -1;
8988
@@ -92,7 +91,6 @@ const handleSelectKeydownTab = (shiftKey = false) => {
9291
return;
9392
}
9493
95-
refSelectOptions.value[index].classList.remove('Select__option--active');
9694
refSelectOptions.value[index].setAttribute('aria-selected', 'false');
9795
};
9896
const updateNext = (index: number) => {
@@ -101,31 +99,30 @@ const handleSelectKeydownTab = (shiftKey = false) => {
10199
}
102100
103101
refSelectOptions.value[index].focus()
104-
refSelectOptions.value[index].classList.add('Select__option--active');
105102
refSelectOptions.value[index].setAttribute('aria-selected', 'true');
106103
};
107104
108-
if (activeSelectOptionIndex === -1) {
105+
if (activeElementIndex === -1) {
109106
updateNext(0);
110107
}
111108
else {
112109
let nextSelectOptionIndex: number;
113110
114111
if (!shiftKey) {
115112
// If active index === length of the options, go to start; move forward 1
116-
nextSelectOptionIndex = activeSelectOptionIndex === refSelectOptions.value.length - 1
113+
nextSelectOptionIndex = activeElementIndex === refSelectOptions.value.length - 1
117114
? 0
118-
: activeSelectOptionIndex + 1;
115+
: activeElementIndex + 1;
119116
}
120117
else {
121118
// If active index is at start, go to end; move backward 1
122-
nextSelectOptionIndex = !activeSelectOptionIndex
119+
nextSelectOptionIndex = !activeElementIndex
123120
? refSelectOptions.value.length - 1
124-
: activeSelectOptionIndex - 1;
121+
: activeElementIndex - 1;
125122
}
126123
127124
// Update current
128-
updateCurrent(activeSelectOptionIndex);
125+
updateCurrent(activeElementIndex);
129126
130127
// Update next
131128
updateNext(nextSelectOptionIndex);
@@ -206,10 +203,6 @@ watch(focused, (focused) => {
206203
onBeforeUnmount(() => {
207204
// REMOVE EVENT LISTENERS
208205
window.removeEventListener('keydown', handleInputFocus);
209-
210-
if (refSelectInput.value) {
211-
refSelectInput.value.removeEventListener('blur', handleSelectBlur);
212-
}
213206
})
214207
215208
onMounted(() => {
@@ -242,8 +235,8 @@ onMounted(() => {
242235
>
243236
<li
244237
v-for="(option, index) in substringSearchMatches"
245-
@keydown="handleSelectKeydown($event, option)"
246238
@click="handleSelectClick($event, option)"
239+
@keydown="handleSelectKeydown($event, option)"
247240
:key="index"
248241
:aria-selected="false"
249242
class="Select__option BaseSelect__option"
@@ -281,6 +274,7 @@ onMounted(() => {
281274
}
282275
283276
&__select {
277+
background-color: map.get($base-color, "body");
284278
border: none;
285279
left: 0;
286280
position: absolute;

0 commit comments

Comments
 (0)