Skip to content

Commit a537ca3

Browse files
committed
Always clear global anchors for dropdown
1 parent 10d1d3b commit a537ca3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/components/FormInputs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export class DropDownInputComponent<Value extends string> extends InputForm<Valu
9191
});
9292

9393
this.button.onClick(() => {
94-
this.wrapper.append(dropDownPopover.draw());
95-
dropDownPopover.showPopover();
94+
dropDownPopover.clearAnchors("--wdropdown-default");
9695
this.button.setAnchorName("--wdropdown-default");
96+
dropDownPopover.showPopover();
9797
content.setValue(Grid(
9898
Items(asRef(dropdown), item =>
9999
Button(item)

src/components/Popover.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const Popover = (content: Component) => new class extends Component {
77
this.addClass("wpopover");
88
this.wrapper.append(content.draw());
99
this.setAttribute("popover");
10+
document.body.append(this.draw());
1011
}
1112

1213
public showPopover() {
@@ -33,6 +34,11 @@ export const Popover = (content: Component) => new class extends Component {
3334
return this;
3435
};
3536

37+
public clearAnchors(anchorName: `--${string}`) {
38+
const anchors = document.querySelectorAll(`[anchor="${anchorName}"]`);
39+
anchors.forEach(anchor => anchor.removeAttribute("anchor"));
40+
return this;
41+
}
3642
public pullingAnchorPositioning(anchorName: `--${string}`, positioning: (rect: DOMRect, style: CSSStyleDeclaration) => void, interval = 20) {
3743
setInterval(() => {
3844
const anchor = document.querySelector(`[anchor="${anchorName}"]`);

0 commit comments

Comments
 (0)