1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-13 22:00:28 +05:30

Merge pull request #2980 from Bnyro/anchor-search-suggestions

feat: allow middle clicks to open search suggestions in new tab
This commit is contained in:
Kavin 2023-09-25 13:24:05 +00:00 committed by GitHub
commit 1bedd48292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -183,7 +183,9 @@ export default {
this.suggestionsVisible = true;
},
onInputBlur() {
this.suggestionsVisible = false;
// the search suggestions will be hidden after some seconds
// otherwise anchor links won't work!
setTimeout(() => (this.suggestionsVisible = false), 200);
},
onSearchTextChange(searchText) {
this.searchText = searchText;

View File

@ -1,15 +1,14 @@
<template>
<div class="suggestions-container absolute">
<ul>
<li
v-for="(suggestion, i) in searchSuggestions"
:key="i"
class="suggestion"
:class="{ 'suggestion-selected': selected === i }"
@mouseover="onMouseOver(i)"
@mousedown.stop="onClick(i)"
v-text="suggestion"
/>
<li v-for="(suggestion, i) in searchSuggestions" :key="i" @mouseover="onMouseOver(i)">
<router-link
class="suggestion"
:class="{ 'suggestion-selected': selected === i }"
:to="`/results?search_query=${encodeURIComponent(suggestion)}`"
>{{ suggestion }}</router-link
>
</li>
</ul>
</div>
</template>
@ -71,10 +70,6 @@ export default {
},
onClick(i) {
this.setSelected(i);
this.$router.push({
name: "SearchResults",
query: { search_query: this.searchSuggestions[i] },
});
},
setSelected(val) {
this.selected = val;
@ -102,6 +97,6 @@ export default {
}
.suggestion {
@apply p-1;
@apply block w-full p-1;
}
</style>