This repository was archived by the owner on Jun 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 1717 :filter =" value"
1818 :highlighted-index =" highlightedIndex"
1919 :selected =" selectedRegion"
20- @highlight =" onHighlightRegion"
2120 @select =" onSelectRegion"
2221 />
2322 <a
@@ -74,9 +73,6 @@ export default {
7473 this .highlightedIndex += 1 ;
7574 }
7675 },
77- onHighlightRegion (region ) {
78- this .highlightedIndex = this .filteredRegions .findIndex (reg => reg .name === region .name );
79- },
8076 onInput (value ) {
8177 this .value = value;
8278 this .highlightedIndex = 0 ;
Original file line number Diff line number Diff line change 11<template >
22 <li
33 :data-selected =" region.locale"
4- :class =" { [$style.highlighted]: highlighted }"
5- @mouseenter =" $emit('highlight', region)"
4+ :class =" [$style.item, { [$style.highlighted]: highlighted }]"
65 @click =" $emit('select')"
76 >
87 <span :class =" `flag ${country}`" />
@@ -26,7 +25,11 @@ export default {
2625 </script >
2726
2827<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 );
3134}
3235 </style >
Original file line number Diff line number Diff line change 44 <span :class =" selected.class" />
55 <strong class =" js-selected-text" >{{ selected.name }}</strong >
66 </p >
7- <ul class =" flags-dropdown-list" >
7+ <ul
8+ ref =" regionItems"
9+ class =" flags-dropdown-list"
10+ >
811 <RegionItem
912 v-for =" (region, index) in regions"
1013 :key =" region.id"
1114 :region =" region"
1215 :highlighted =" index === highlightedIndex"
13- @highlight =" highlight"
1416 @select =" $emit('select')"
1517 />
1618 </ul >
@@ -31,10 +33,13 @@ export default {
3133 highlightedIndex: { type: Number , required: true },
3234 selected: { type: Object , default : () => ({}) },
3335 },
34- methods : {
35- highlight ( region ) {
36- this .$emit ( ' highlight ' , region) ;
36+ computed : {
37+ listItemHeight ( ) {
38+ return this .$refs . regionItems . querySelector ( ' li ' ). clientHeight ;
3739 },
3840 },
41+ beforeUpdate () {
42+ this .$refs .regionItems .scrollTop = this .listItemHeight * this .highlightedIndex ;
43+ },
3944};
4045 </script >
You can’t perform that action at this time.
0 commit comments