@@ -4,8 +4,6 @@ import {isDocumentFragmentOrElementNode, toggleClass} from '../utils/dom.ts';
44import octiconKebabHorizontal from '../../../public/assets/img/svg/octicon-kebab-horizontal.svg' ;
55
66window . customElements . define ( 'overflow-menu' , class extends HTMLElement {
7- static observedAttributes = [ 'active' ] ;
8-
97 tippyContent : HTMLDivElement ;
108 tippyItems : Array < HTMLElement > ;
119 button : HTMLButtonElement ;
@@ -104,7 +102,16 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
104102 const itemRight = item . offsetLeft + item . offsetWidth ;
105103 if ( menuRight - itemRight < 38 ) { // roughly the width of .overflow-menu-button with some extra space
106104 this . tippyItems . push ( item ) ;
105+
106+ // close tippy when clicking item of tippy
107+ item . addEventListener ( 'click' , ( ) => {
108+ this . button ?. _tippy . hide ( ) ;
109+ } ) ;
107110 }
111+ // refresh overflow-button active state
112+ item . addEventListener ( 'click' , ( ) => {
113+ this . updateButtonActivationState ( ) ;
114+ } ) ;
108115 }
109116 itemFlexSpace ?. style . removeProperty ( 'display' ) ;
110117 itemOverFlowMenuButton ?. style . removeProperty ( 'display' ) ;
@@ -130,14 +137,6 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
130137 this . tippyContent . append ( item ) ;
131138 }
132139
133- // close tippy when clicking item of tippy
134- const items = this . tippyContent . querySelectorAll < HTMLElement > ( '.item' ) ;
135- for ( const item of items ) {
136- item . addEventListener ( 'click' , ( ) => {
137- this . button ?. _tippy . hide ( ) ;
138- } ) ;
139- }
140-
141140 // update existing tippy
142141 if ( this . button ?. _tippy ) {
143142 this . button . _tippy . setContent ( this . tippyContent ) ;
@@ -235,10 +234,6 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
235234 }
236235 }
237236
238- attributeChangedCallback ( ) {
239- this . updateButtonActivationState ( ) ;
240- }
241-
242237 disconnectedCallback ( ) {
243238 this . mutationObserver ?. disconnect ( ) ;
244239 this . resizeObserver ?. disconnect ( ) ;
0 commit comments