forked from retoor/devplacepy
Position the More action menu under its trigger and align form-wrapped items
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -165,6 +165,26 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action-menu-panel > form {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-menu-panel > form > button {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.5rem 0.625rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: none;
|
||||||
|
color: inherit;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.action-menu-panel > form,
|
.action-menu-panel > form,
|
||||||
.action-menu-panel > a,
|
.action-menu-panel > a,
|
||||||
.action-menu-panel > button {
|
.action-menu-panel > button {
|
||||||
|
|||||||
@@ -83,9 +83,36 @@ export class AppActionMenu extends Component {
|
|||||||
this.panel.hidden = false;
|
this.panel.hidden = false;
|
||||||
}
|
}
|
||||||
this.trigger.setAttribute("aria-expanded", "true");
|
this.trigger.setAttribute("aria-expanded", "true");
|
||||||
|
this.place();
|
||||||
|
this.onViewportChange = this.onViewportChange || (() => this.close());
|
||||||
|
window.addEventListener("resize", this.onViewportChange);
|
||||||
|
window.addEventListener("scroll", this.onViewportChange, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
place() {
|
||||||
|
const gap = 4;
|
||||||
|
const edge = 8;
|
||||||
|
const anchor = this.trigger.getBoundingClientRect();
|
||||||
|
const panel = this.panel.getBoundingClientRect();
|
||||||
|
const room = window.innerWidth - edge * 2;
|
||||||
|
let left = anchor.left;
|
||||||
|
if (left + panel.width > window.innerWidth - edge) left = anchor.right - panel.width;
|
||||||
|
left = Math.max(edge, Math.min(left, window.innerWidth - edge - Math.min(panel.width, room)));
|
||||||
|
let top = anchor.bottom + gap;
|
||||||
|
if (top + panel.height > window.innerHeight - edge) {
|
||||||
|
const above = anchor.top - gap - panel.height;
|
||||||
|
top = above >= edge ? above : Math.max(edge, window.innerHeight - edge - panel.height);
|
||||||
|
}
|
||||||
|
this.panel.style.left = `${Math.round(left)}px`;
|
||||||
|
this.panel.style.top = `${Math.round(top)}px`;
|
||||||
|
this.panel.style.maxHeight = `${window.innerHeight - edge * 2}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
if (this.onViewportChange) {
|
||||||
|
window.removeEventListener("resize", this.onViewportChange);
|
||||||
|
window.removeEventListener("scroll", this.onViewportChange, true);
|
||||||
|
}
|
||||||
if (typeof this.panel.hidePopover === "function" && this.panel.matches(":popover-open")) {
|
if (typeof this.panel.hidePopover === "function" && this.panel.matches(":popover-open")) {
|
||||||
this.panel.hidePopover();
|
this.panel.hidePopover();
|
||||||
} else if (!this.panel.hasAttribute("popover")) {
|
} else if (!this.panel.hasAttribute("popover")) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "devplacepy"
|
name = "devplacepy"
|
||||||
version = "1.1.21"
|
version = "1.1.22"
|
||||||
description = "DevPlace - The Developer Social Network"
|
description = "DevPlace - The Developer Social Network"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
Reference in New Issue
Block a user