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