@@ -81,12 +81,12 @@ function showLineButton() {
8181el . 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' ) ;
9090const btn = document . createElement ( 'button' ) ;
9191btn . classList . add ( 'code-line-button' , 'ui' , 'basic' , 'button' ) ;
9292btn . innerHTML = svg ( 'octicon-kebab-horizontal' ) ;
@@ -97,28 +97,28 @@ function showLineButton() {
9797
9898createTippy ( btn , {
9999theme :'menu' ,
100- trigger :'manual' , // Use manual trigger
100+ trigger :'click' ,
101+ hideOnClick :true ,
101102content :menu ,
102103placement :'right-start' ,
103104interactive :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
108113btn . addEventListener ( 'click' , ( e ) => {
109114e . stopPropagation ( ) ;
110115const tippyInstance = btn . _tippy ;
111- if ( tippyInstance ?. state . isVisible ) {
116+ if ( tippyInstance ?. state . isShown ) {
112117tippyInstance . hide ( ) ;
113118} else if ( tippyInstance ) {
114119tippyInstance . 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 ( ) {