@@ -39,7 +39,7 @@ export default defineComponent({
3939 return {
4040 tab ,
4141 repos: [],
42- reposTotalCount: 0 ,
42+ reposTotalCount: null ,
4343 reposFilter ,
4444 archivedFilter ,
4545 privateFilter ,
@@ -113,9 +113,6 @@ export default defineComponent({
113113 const el = document .querySelector (' #dashboard-repo-list' );
114114 this .changeReposFilter (this .reposFilter );
115115 fomanticQuery (el .querySelector (' .ui.dropdown' )).dropdown ();
116- nextTick (() => {
117- this .$refs .search ?.focus ();
118- });
119116
120117 this .textArchivedFilterTitles = {
121118 ' archived' : this .textShowOnlyArchived ,
@@ -243,12 +240,20 @@ export default defineComponent({
243240
244241 let response, json;
245242 try {
243+ const firstLoad = this .reposTotalCount === null ;
246244 if (! this .reposTotalCount ) {
247245 const totalCountSearchURL = ` ${this .subUrl }/repo/search?count_only=1&uid=${this .uid }&team_id=${this .teamId }&q=&page=1&mode= ` ;
248246 response = await GET (totalCountSearchURL );
249247 this .reposTotalCount = parseInt (response .headers .get (' X-Total-Count' ) ?? ' 0' );
250248 }
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+ }
252257 response = await GET (searchedURL );
253258 json = await response .json ();
254259 } catch {
@@ -350,7 +355,7 @@ export default defineComponent({
350355 <h4 class =" ui top attached header tw-flex tw-items-center" >
351356 <div class =" tw-flex-1 tw-flex tw-items-center" >
352357 {{ 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 >
354359 </div >
355360 <a class =" tw-flex tw-items-center muted" :href =" subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content =" textNewRepo" >
356361 <svg-icon name =" octicon-plus" />
@@ -421,7 +426,7 @@ export default defineComponent({
421426 </div >
422427 <div v-if =" repos.length" class =" ui attached table segment tw-rounded-b" >
423428 <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" >
425430 <a class =" repo-list-link muted" :href =" repo.link" >
426431 <svg-icon :name =" repoIcon(repo)" :size =" 16" class =" repo-list-icon" />
427432 <div class =" text truncate" >{{ repo.full_name }}</div >
0 commit comments