File tree Expand file tree Collapse file tree 3 files changed +27
-10
lines changed
Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 11: host {
22 dis play: contents;
33}
4+
5+ [part = label ] {
6+ text-align : left;
7+ }
Original file line number Diff line number Diff line change 11: host {
22 dis play: contents;
33}
4+
5+ [part = "overlay" ] {
6+ position-area : end center;
7+ margin : 0 ;
8+ min-width : anchor-size ();
9+ padding : 0 ;
10+ border : 0 ;
11+ }
Original file line number Diff line number Diff line change @@ -24,24 +24,29 @@ export default class PgOverlayMenu extends PgOverlay {
2424 }
2525 }
2626
27- #handleMouseDown;
2827 connectedCallback ( ) {
29- this . #handleMouseDown = ( e : any ) => {
30- if ( e . target !== this ) {
31- this . close ( ) ;
32- }
33- } ;
34- document . addEventListener ( 'mousedown' , this . #handleMouseDown) ;
3528 this . $menu . addEventListener ( 'select' , this . #handleSelect. bind ( this ) ) ;
36- this . $overlay . id = `overlayMenu${ this . #uniqueId++ } ` ;
29+ this . $overlay . popover = 'auto' ;
30+ if ( this . source !== null ) {
31+ // @ts -ignore
32+ this . $overlay . showPopover ( {
33+ source : this . source
34+ } ) ;
35+ }
36+ this . $overlay . addEventListener ( 'toggle' , this . #toggle. bind ( this ) ) ;
37+ }
38+
39+ #toggle( e : ToggleEvent ) {
40+ console . log ( e . newState ) ;
41+ if ( e . newState === 'closed' ) {
42+ this . close ( ) ;
43+ }
3744 }
3845
3946 disconnectedCallback ( ) {
40- document . removeEventListener ( 'mousedown' , this . #handleMouseDown) ;
4147 }
4248
4349 #handleSelect( e : any ) {
4450 this . close ( e . detail . index ) ;
45- this . source ?. focus ( ) ;
4651 }
4752}
You can’t perform that action at this time.
0 commit comments