Skip to content
This repository was archived by the owner on Jun 13, 2021. It is now read-only.

Commit c78060c

Browse files
committed
fix: restore mouse selection
1 parent d7ddecd commit c78060c

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/components/App.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:regions="filteredRegions"
1717
:filter="value"
1818
:highlighted-index="highlightedIndex"
19-
:selected="selectedRegion"
19+
:current-region="currentRegion"
2020
@select="onSelectRegion"
2121
/>
2222
<a
@@ -37,7 +37,7 @@ export default {
3737
RegionsList,
3838
},
3939
props: {
40-
regions: { type: Object, required: true },
40+
regions: { type: Array, required: true },
4141
cookieString: { type: String, required: true },
4242
moreParameters: { type: Object, required: true },
4343
},
@@ -54,7 +54,7 @@ export default {
5454
.find(param => param.startsWith('mc='))
5555
.substr(3);
5656
},
57-
selectedRegion() {
57+
currentRegion() {
5858
return this.regions.filter(region => region.locale === this.selectedLocale)[0];
5959
},
6060
filteredRegions() {
@@ -77,14 +77,14 @@ export default {
7777
this.value = value;
7878
this.highlightedIndex = 0;
7979
},
80-
onSelectRegion() {
80+
onSelectRegion(region = this.filteredRegions[this.highlightedIndex]) {
8181
const updatedCookieString = this.cookieString
8282
.split(':')
8383
.map((paramString) => {
8484
const [name, value] = paramString.split('=');
8585
return {
8686
name,
87-
value: name === 'mc' ? this.filteredRegions[this.highlightedIndex].locale : value,
87+
value: name === 'mc' ? region.locale : value,
8888
};
8989
})
9090
.reduce((accCookieString, param) => {

src/components/RegionItem.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<li
33
:data-selected="region.locale"
44
:class="[$style.item, { [$style.highlighted]: highlighted }]"
5-
@click="$emit('select')"
5+
@click="$emit('select', region)"
66
>
77
<span :class="`flag ${country}`" />
88
{{ region.name }}

src/components/RegionsList.vue

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div class="flags-dropdown-body">
33
<p class="flags-dropdown-chosen js-select-chosen">
4-
<span :class="selected.class" />
5-
<strong class="js-selected-text">{{ selected.name }}</strong>
4+
<span :class="currentRegion.class" />
5+
<strong class="js-selected-text">{{ currentRegion.name }}</strong>
66
</p>
77
<ul
88
ref="regionItems"
@@ -13,7 +13,7 @@
1313
:key="region.id"
1414
:region="region"
1515
:highlighted="index === highlightedIndex"
16-
@select="$emit('select')"
16+
@select="selectRegion"
1717
/>
1818
</ul>
1919
</div>
@@ -28,10 +28,10 @@ export default {
2828
RegionItem,
2929
},
3030
props: {
31-
regions: { type: Object, required: true },
31+
regions: { type: Array, required: true },
3232
filter: { type: String, required: true },
3333
highlightedIndex: { type: Number, required: true },
34-
selected: { type: Object, default: () => ({}) },
34+
currentRegion: { type: Object, default: () => ({}) },
3535
},
3636
computed: {
3737
listItemHeight() {
@@ -41,5 +41,10 @@ export default {
4141
beforeUpdate() {
4242
this.$refs.regionItems.scrollTop = this.listItemHeight * this.highlightedIndex;
4343
},
44+
methods: {
45+
selectRegion(region) {
46+
this.$emit('select', region);
47+
},
48+
},
4449
};
4550
</script>

0 commit comments

Comments
 (0)