|
17 | 17 | </h4>
|
18 | 18 | <div class="ui attached segment repos-search">
|
19 | 19 | <div class="ui fluid right action left icon input" :class="{loading: isLoading}">
|
20 |
| - <input @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" :placeholder="textSearchRepos"> |
| 20 | + <input @input="changeReposFilter(reposFilter)" v-model="searchQuery" ref="search" @keydown="reposFilterKeyControl" :placeholder="textSearchRepos"> |
21 | 21 | <i class="icon gt-df gt-ac gt-jc"><svg-icon name="octicon-search" :size="16"/></i>
|
22 | 22 | <div class="ui dropdown icon button" :title="textFilter">
|
23 | 23 | <i class="icon gt-df gt-ac gt-jc gt-m-0"><svg-icon name="octicon-filter" :size="16"/></i>
|
|
70 | 70 | </div>
|
71 | 71 | <div v-if="repos.length" class="ui attached table segment gt-rounded-bottom">
|
72 | 72 | <ul class="repo-owner-name-list">
|
73 |
| - <li class="gt-df gt-ac" v-for="repo in repos" :key="repo.id"> |
| 73 | + <li class="gt-df gt-ac" v-for="repo, index in repos" :class="{'active': index === activeIndex}" :key="repo.id"> |
74 | 74 | <a class="repo-list-link muted gt-df gt-ac gt-f1" :href="repo.link">
|
75 | 75 | <svg-icon :name="repoIcon(repo)" :size="16" class-name="repo-list-icon"/>
|
76 | 76 | <div class="text truncate">{{ repo.full_name }}</div>
|
@@ -215,6 +215,7 @@ const sfc = {
|
215 | 215 |
|
216 | 216 | subUrl: appSubUrl,
|
217 | 217 | ...pageData.dashboardRepoList,
|
| 218 | + activeIndex: -1, // don't select anything at load, first cursor down will select |
218 | 219 | };
|
219 | 220 | },
|
220 | 221 |
|
@@ -429,6 +430,43 @@ const sfc = {
|
429 | 430 |
|
430 | 431 | statusColor(status) {
|
431 | 432 | return commitStatus[status].color;
|
| 433 | + }, |
| 434 | +
|
| 435 | + reposFilterKeyControl(e) { |
| 436 | + switch (e.key) { |
| 437 | + case 'Enter': |
| 438 | + document.querySelector('.repo-owner-name-list li.active a')?.click(); |
| 439 | + break; |
| 440 | + case 'ArrowUp': |
| 441 | + if (this.activeIndex > 0) { |
| 442 | + this.activeIndex--; |
| 443 | + } else if (this.page > 1) { |
| 444 | + this.changePage(this.page - 1); |
| 445 | + this.activeIndex = this.searchLimit - 1; |
| 446 | + } |
| 447 | + break; |
| 448 | + case 'ArrowDown': |
| 449 | + if (this.activeIndex < this.repos.length - 1) { |
| 450 | + this.activeIndex++; |
| 451 | + } else if (this.page < this.finalPage) { |
| 452 | + this.activeIndex = 0; |
| 453 | + this.changePage(this.page + 1); |
| 454 | + } |
| 455 | + break; |
| 456 | + case 'ArrowRight': |
| 457 | + if (this.page < this.finalPage) { |
| 458 | + this.changePage(this.page + 1); |
| 459 | + } |
| 460 | + break; |
| 461 | + case 'ArrowLeft': |
| 462 | + if (this.page > 1) { |
| 463 | + this.changePage(this.page - 1); |
| 464 | + } |
| 465 | + break; |
| 466 | + } |
| 467 | + if (this.activeIndex === -1 || this.activeIndex > this.repos.length - 1) { |
| 468 | + this.activeIndex = 0; |
| 469 | + } |
432 | 470 | }
|
433 | 471 | },
|
434 | 472 | };
|
@@ -480,4 +518,8 @@ ul li:not(:last-child) {
|
480 | 518 | margin-left: 1px;
|
481 | 519 | margin-right: 3px;
|
482 | 520 | }
|
| 521 | +
|
| 522 | +.repo-owner-name-list li.active { |
| 523 | + background: var(--color-hover); |
| 524 | +} |
483 | 525 | </style>
|
0 commit comments