@@ -81,12 +81,11 @@ function showLineButton() {
8181 el . remove ( ) ;
8282 }
8383
84- // Find first active row and add button
85- const activeRows = document . querySelectorAll ( '.code-view tr.active' ) ;
86- if ( activeRows . length === 0 ) return ;
84+ // find active row and add button
85+ const tr = document . querySelector ( '.code-view tr.active' ) ;
86+ if ( ! tr ) return ;
8787
88- const firstActiveRow = activeRows [ 0 ] ;
89- const td = firstActiveRow . querySelector ( 'td.lines-num' ) ;
88+ const td = tr . querySelector ( 'td.lines-num' ) ;
9089 const btn = document . createElement ( 'button' ) ;
9190 btn . classList . add ( 'code-line-button' , 'ui' , 'basic' , 'button' ) ;
9291 btn . innerHTML = svg ( 'octicon-kebab-horizontal' ) ;
@@ -97,28 +96,28 @@ function showLineButton() {
9796
9897 createTippy ( btn , {
9998 theme : 'menu' ,
100- trigger : 'manual' , // Use manual trigger
99+ trigger : 'click' ,
100+ hideOnClick : true ,
101101 content : menu ,
102102 placement : 'right-start' ,
103103 interactive : true ,
104- appendTo : ( ) => document . body ,
104+ onShow : ( tippy ) => {
105+ tippy . popper . addEventListener ( 'click' , ( ) => {
106+ tippy . hide ( ) ;
107+ } , { once : true } ) ;
108+ } ,
105109 } ) ;
106110
107111 // Handle menu button click manually
108112 btn . addEventListener ( 'click' , ( e ) => {
109113 e . stopPropagation ( ) ;
110114 const tippyInstance = btn . _tippy ;
111- if ( tippyInstance ?. state . isVisible ) {
115+ if ( tippyInstance ?. state . isShown ) {
112116 tippyInstance . hide ( ) ;
113117 } else if ( tippyInstance ) {
114118 tippyInstance . show ( ) ;
115119 }
116120 } ) ;
117-
118- // Hide menu when clicking menu items
119- menu . addEventListener ( 'click' , ( ) => {
120- btn . _tippy ?. hide ( ) ;
121- } ) ;
122121}
123122
124123export function initRepoCodeView ( ) {
0 commit comments