@@ -81,12 +81,12 @@ 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 ;
87+
88+ const td = tr . querySelector ( 'td.lines-num' ) ;
8789
88- const firstActiveRow = activeRows [ 0 ] ;
89- const td = firstActiveRow . querySelector ( 'td.lines-num' ) ;
9090 const btn = document . createElement ( 'button' ) ;
9191 btn . classList . add ( 'code-line-button' , 'ui' , 'basic' , 'button' ) ;
9292 btn . innerHTML = svg ( 'octicon-kebab-horizontal' ) ;
@@ -97,28 +97,28 @@ function showLineButton() {
9797
9898 createTippy ( btn , {
9999 theme : 'menu' ,
100- trigger : 'manual' , // Use manual trigger
100+ trigger : 'click' ,
101+ hideOnClick : true ,
101102 content : menu ,
102103 placement : 'right-start' ,
103104 interactive : true ,
104- appendTo : ( ) => document . body ,
105+ onShow : ( tippy ) => {
106+ tippy . popper . addEventListener ( 'click' , ( ) => {
107+ tippy . hide ( ) ;
108+ } , { once : true } ) ;
109+ } ,
105110 } ) ;
106111
107112 // Handle menu button click manually
108113 btn . addEventListener ( 'click' , ( e ) => {
109114 e . stopPropagation ( ) ;
110115 const tippyInstance = btn . _tippy ;
111- if ( tippyInstance ?. state . isVisible ) {
116+ if ( tippyInstance ?. state . isShown ) {
112117 tippyInstance . hide ( ) ;
113118 } else if ( tippyInstance ) {
114119 tippyInstance . show ( ) ;
115120 }
116121 } ) ;
117-
118- // Hide menu when clicking menu items
119- menu . addEventListener ( 'click' , ( ) => {
120- btn . _tippy ?. hide ( ) ;
121- } ) ;
122122}
123123
124124export function initRepoCodeView ( ) {
0 commit comments