@@ -81,12 +81,11 @@ function showLineButton() {
81
81
el . remove ( ) ;
82
82
}
83
83
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
87
88
- const firstActiveRow = activeRows [ 0 ] ;
89
- const td = firstActiveRow . querySelector ( 'td.lines-num' ) ;
88
+ const td = tr . querySelector ( 'td.lines-num' ) ;
90
89
const btn = document . createElement ( 'button' ) ;
91
90
btn . classList . add ( 'code-line-button' , 'ui' , 'basic' , 'button' ) ;
92
91
btn . innerHTML = svg ( 'octicon-kebab-horizontal' ) ;
@@ -97,28 +96,28 @@ function showLineButton() {
97
96
98
97
createTippy ( btn , {
99
98
theme : 'menu' ,
100
- trigger : 'manual' , // Use manual trigger
99
+ trigger : 'click' ,
100
+ hideOnClick : true ,
101
101
content : menu ,
102
102
placement : 'right-start' ,
103
103
interactive : true ,
104
- appendTo : ( ) => document . body ,
104
+ onShow : ( tippy ) => {
105
+ tippy . popper . addEventListener ( 'click' , ( ) => {
106
+ tippy . hide ( ) ;
107
+ } , { once : true } ) ;
108
+ } ,
105
109
} ) ;
106
110
107
111
// Handle menu button click manually
108
112
btn . addEventListener ( 'click' , ( e ) => {
109
113
e . stopPropagation ( ) ;
110
114
const tippyInstance = btn . _tippy ;
111
- if ( tippyInstance ?. state . isVisible ) {
115
+ if ( tippyInstance ?. state . isShown ) {
112
116
tippyInstance . hide ( ) ;
113
117
} else if ( tippyInstance ) {
114
118
tippyInstance . show ( ) ;
115
119
}
116
120
} ) ;
117
-
118
- // Hide menu when clicking menu items
119
- menu . addEventListener ( 'click' , ( ) => {
120
- btn . _tippy ?. hide ( ) ;
121
- } ) ;
122
121
}
123
122
124
123
export function initRepoCodeView ( ) {
0 commit comments