Skip to content

Commit 96f5391

Browse files
committed
Progress.
1 parent 83aee4e commit 96f5391

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/pg/menuItem/menuItem.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
:host {
22
display: contents;
33
}
4+
5+
[part=label] {
6+
text-align: left;
7+
}

src/pg/overlayMenu/overlayMenu.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
:host {
22
display: 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+
}

src/pg/overlayMenu/overlayMenu.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)