@@ -38,7 +38,7 @@ export default defineComponent({
38
38
return {
39
39
tab ,
40
40
repos: [],
41
- reposTotalCount: 0 ,
41
+ reposTotalCount: null ,
42
42
reposFilter ,
43
43
archivedFilter ,
44
44
privateFilter ,
@@ -112,9 +112,6 @@ export default defineComponent({
112
112
const el = document .querySelector (' #dashboard-repo-list' );
113
113
this .changeReposFilter (this .reposFilter );
114
114
fomanticQuery (el .querySelector (' .ui.dropdown' )).dropdown ();
115
- nextTick (() => {
116
- this .$refs .search ?.focus ();
117
- });
118
115
119
116
this .textArchivedFilterTitles = {
120
117
' archived' : this .textShowOnlyArchived ,
@@ -242,12 +239,20 @@ export default defineComponent({
242
239
243
240
let response, json;
244
241
try {
242
+ const firstLoad = this .reposTotalCount === null ;
245
243
if (! this .reposTotalCount ) {
246
244
const totalCountSearchURL = ` ${this .subUrl }/repo/search?count_only=1&uid=${this .uid }&team_id=${this .teamId }&q=&page=1&mode= ` ;
247
245
response = await GET (totalCountSearchURL );
248
246
this .reposTotalCount = parseInt (response .headers .get (' X-Total-Count' ) ?? ' 0' );
249
247
}
250
-
248
+ if (firstLoad && this .reposTotalCount ) {
249
+ nextTick (() => {
250
+ // MDN: If there's no focused element, this is the Document.body or Document.documentElement.
251
+ if ((document .activeElement === document .body || document .activeElement === document .documentElement )) {
252
+ this .$refs .search .focus ({preventScroll: true });
253
+ }
254
+ });
255
+ }
251
256
response = await GET (searchedURL );
252
257
json = await response .json ();
253
258
} catch {
@@ -349,7 +354,7 @@ export default defineComponent({
349
354
<h4 class =" ui top attached header tw-flex tw-items-center" >
350
355
<div class =" tw-flex-1 tw-flex tw-items-center" >
351
356
{{ textMyRepos }}
352
- <span class =" ui grey label tw-ml-2" >{{ reposTotalCount }}</span >
357
+ <span v-if = " reposTotalCount " class =" ui grey label tw-ml-2" >{{ reposTotalCount }}</span >
353
358
</div >
354
359
<a class =" tw-flex tw-items-center muted" :href =" subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content =" textNewRepo" >
355
360
<svg-icon name =" octicon-plus" />
@@ -420,7 +425,7 @@ export default defineComponent({
420
425
</div >
421
426
<div v-if =" repos.length" class =" ui attached table segment tw-rounded-b" >
422
427
<ul class =" repo-owner-name-list" >
423
- <li class =" tw-flex tw-items-center tw-py-2" v-for =" repo, index in repos" :class =" {'active': index === activeIndex}" :key =" repo.id" >
428
+ <li class =" tw-flex tw-items-center tw-py-2" v-for =" ( repo, index) in repos" :class =" {'active': index === activeIndex}" :key =" repo.id" >
424
429
<a class =" repo-list-link muted" :href =" repo.link" >
425
430
<svg-icon :name =" repoIcon(repo)" :size =" 16" class =" repo-list-icon" />
426
431
<div class =" text truncate" >{{ repo.full_name }}</div >
0 commit comments