1- import { isElemVisible , onInputDebounce , submitEventSubmitter , toggleElem } from '../utils/dom.ts' ;
1+ import { onInputDebounce , toggleElem } from '../utils/dom.ts' ;
22import { GET } from '../modules/fetch.ts' ;
33
44const { appSubUrl} = window . config ;
@@ -17,37 +17,25 @@ export function parseIssueListQuickGotoLink(repoLink: string, searchText: string
1717 } else if ( reIssueSharpIndex . test ( searchText ) ) {
1818 targetUrl = `${ repoLink } /issues/${ searchText . substring ( 1 ) } ` ;
1919 }
20- } else {
21- // try to parse it for a global search (eg: "owner/repo#123")
22- const [ _ , owner , repo , index ] = reIssueOwnerRepoIndex . exec ( searchText ) || [ ] ;
23- if ( owner ) {
24- targetUrl = `${ appSubUrl } /${ owner } /${ repo } /issues/${ index } ` ;
25- }
20+ }
21+ // try to parse it for a global search (eg: "owner/repo#123")
22+ const [ _ , owner , repo , index ] = reIssueOwnerRepoIndex . exec ( searchText ) || [ ] ;
23+ if ( owner ) {
24+ targetUrl = `${ appSubUrl } /${ owner } /${ repo } /issues/${ index } ` ;
2625 }
2726 return targetUrl ;
2827}
2928
3029export function initCommonIssueListQuickGoto ( ) {
31- const goto = document . querySelector < HTMLElement > ( '#issue-list-quick-goto' ) ;
32- if ( ! goto ) return ;
30+ const elGotoButton = document . querySelector < HTMLElement > ( '#issue-list-quick-goto' ) ;
31+ if ( ! elGotoButton ) return ;
3332
34- const form = goto . closest ( 'form' ) ! ;
33+ const form = elGotoButton . closest ( 'form' ) ! ;
3534 const input = form . querySelector < HTMLInputElement > ( 'input[name=q]' ) ! ;
36- const repoLink = goto . getAttribute ( 'data-repo-link' ) ! ;
35+ const repoLink = elGotoButton . getAttribute ( 'data-repo-link' ) || '' ;
3736
38- form . addEventListener ( 'submit' , ( e ) => {
39- // if there is no goto button, or the form is submitted by non-quick-goto elements, submit the form directly
40- let doQuickGoto = isElemVisible ( goto ) ;
41- const submitter = submitEventSubmitter ( e ) ;
42- if ( submitter !== form && submitter !== input && submitter !== goto ) doQuickGoto = false ;
43- if ( ! doQuickGoto ) return ;
44-
45- // if there is a goto button, use its link
46- e . preventDefault ( ) ;
47- const link = goto . getAttribute ( 'data-issue-goto-link' ) ;
48- if ( link ) {
49- window . location . href = link ;
50- }
37+ elGotoButton . addEventListener ( 'click' , ( ) => {
38+ window . location . href = elGotoButton . getAttribute ( 'data-issue-goto-link' ) ! ;
5139 } ) ;
5240
5341 const onInput = async ( ) => {
@@ -61,8 +49,8 @@ export function initCommonIssueListQuickGoto() {
6149 // if the input value has changed, then ignore the result
6250 if ( input . value !== searchText ) return ;
6351
64- toggleElem ( goto , Boolean ( targetUrl ) ) ;
65- goto . setAttribute ( 'data-issue-goto-link' , targetUrl ) ;
52+ toggleElem ( elGotoButton , Boolean ( targetUrl ) ) ;
53+ elGotoButton . setAttribute ( 'data-issue-goto-link' , targetUrl ) ;
6654 } ;
6755
6856 input . addEventListener ( 'input' , onInputDebounce ( onInput ) ) ;
0 commit comments