Skip to content

Commit d0e429e

Browse files
author
lukas
committed
Open result repository on search enter
1 parent d640632 commit d0e429e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

templates/user/dashboard/repolist.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</h4>
4242
<div class="ui attached segment repos-search">
4343
<div class="ui fluid right action left icon input" :class="{loading: isLoading}">
44-
<input @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" placeholder="{{.locale.Tr "home.search_repos"}}">
44+
<input @input="changeReposFilter(reposFilter)" v-on:keyup.enter="onSearchEnter" v-on:keyup.down="onSearchDown" v-on:keyup.up="onSearchUp" v-model="searchQuery" ref="search" placeholder="{{.locale.Tr "home.search_repos"}}">
4545
<i class="icon df ac jc">{{svg "octicon-search" 16}}</i>
4646
<div class="ui dropdown icon button" title="{{.locale.Tr "home.filter"}}">
4747
<i class="icon df ac jc m-0">{{svg "octicon-filter" 16}}</i>

web_src/js/components/DashboardRepoList.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,41 @@ function initVueComponents(app) {
189189
}
190190
},
191191

192+
onSearchEnter() {
193+
if (this.searchQuery.length > 0) {
194+
const items = document.getElementsByClassName('repo-list-link');
195+
items[this.repoIndex].click();
196+
}
197+
},
198+
199+
onSearchDown() {
200+
if (this.repoIndex + 1 < this.repos.length) {
201+
const items = document.getElementsByClassName('repo-list-link');
202+
items[this.repoIndex].classList.remove('selected');
203+
this.repoIndex++;
204+
items[this.repoIndex].classList.add('selected');
205+
}
206+
},
207+
208+
onSearchUp() {
209+
if (this.repoIndex > 0) {
210+
const items = document.getElementsByClassName('repo-list-link');
211+
items[this.repoIndex].classList.remove('selected');
212+
this.repoIndex--;
213+
items[this.repoIndex].classList.add('selected');
214+
}
215+
},
216+
192217
changeReposFilter(filter) {
193218
this.reposFilter = filter;
194219
this.repos = [];
195220
this.page = 1;
196221
this.counts[`${filter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
197222
this.searchRepos();
223+
setTimeout(() => {
224+
const items = document.getElementsByClassName('repo-list-link');
225+
items[0].classList.add('selected');
226+
}, 100);
198227
},
199228

200229
updateHistory() {

web_src/less/_dashboard.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@
178178
.star-num {
179179
font-size: 12px;
180180
}
181+
182+
&.selected {
183+
outline: solid 1px grey;
184+
}
181185
}
182186
}
183187
}

0 commit comments

Comments
 (0)