This repository was archived by the owner on Jun 13, 2021. It is now read-only.
File tree 3 files changed +17
-13
lines changed
3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 17
17
:filter =" value"
18
18
:highlighted-index =" highlightedIndex"
19
19
:selected =" selectedRegion"
20
- @highlight =" onHighlightRegion"
21
20
@select =" onSelectRegion"
22
21
/>
23
22
<a
@@ -74,9 +73,6 @@ export default {
74
73
this .highlightedIndex += 1 ;
75
74
}
76
75
},
77
- onHighlightRegion (region ) {
78
- this .highlightedIndex = this .filteredRegions .findIndex (reg => reg .name === region .name );
79
- },
80
76
onInput (value ) {
81
77
this .value = value;
82
78
this .highlightedIndex = 0 ;
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<li
3
3
:data-selected =" region.locale"
4
- :class =" { [$style.highlighted]: highlighted }"
5
- @mouseenter =" $emit('highlight', region)"
4
+ :class =" [$style.item, { [$style.highlighted]: highlighted }]"
6
5
@click =" $emit('select')"
7
6
>
8
7
<span :class =" `flag ${country}`" />
@@ -26,7 +25,11 @@ export default {
26
25
</script >
27
26
28
27
<style module>
29
- .highlighted {
30
- background-color : lightblue ;
28
+ .highlighted ,
29
+ .item :hover {
30
+ background-color : rgb (237 , 237 , 237 );
31
+ }
32
+ .highlighted.item :hover {
33
+ background-color : rgb (224 , 224 , 224 );
31
34
}
32
35
</style >
Original file line number Diff line number Diff line change 4
4
<span :class =" selected.class" />
5
5
<strong class =" js-selected-text" >{{ selected.name }}</strong >
6
6
</p >
7
- <ul class =" flags-dropdown-list" >
7
+ <ul
8
+ ref =" regionItems"
9
+ class =" flags-dropdown-list"
10
+ >
8
11
<RegionItem
9
12
v-for =" (region, index) in regions"
10
13
:key =" region.id"
11
14
:region =" region"
12
15
:highlighted =" index === highlightedIndex"
13
- @highlight =" highlight"
14
16
@select =" $emit('select')"
15
17
/>
16
18
</ul >
@@ -31,10 +33,13 @@ export default {
31
33
highlightedIndex: { type: Number , required: true },
32
34
selected: { type: Object , default : () => ({}) },
33
35
},
34
- methods : {
35
- highlight ( region ) {
36
- this .$emit ( ' highlight ' , region) ;
36
+ computed : {
37
+ listItemHeight ( ) {
38
+ return this .$refs . regionItems . querySelector ( ' li ' ). clientHeight ;
37
39
},
38
40
},
41
+ beforeUpdate () {
42
+ this .$refs .regionItems .scrollTop = this .listItemHeight * this .highlightedIndex ;
43
+ },
39
44
};
40
45
</script >
You can’t perform that action at this time.
0 commit comments