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