From 3f6e83c75352ab2b85b36db03b88744b8da246f0 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 12 Nov 2026 15:42:48 +0100 Subject: [PATCH] Position the More action menu under its trigger and align form-wrapped items Co-Authored-By: Claude Sonnet 5.5 --- devplacepy/static/css/components.css | 20 ++++++++++++++ .../static/js/components/AppActionMenu.js | 27 +++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/devplacepy/static/css/components.css b/devplacepy/static/css/components.css index 43f05f04..58aa57a6 100644 --- a/devplacepy/static/css/components.css +++ b/devplacepy/static/css/components.css @@ -165,6 +165,26 @@ 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 > a, .action-menu-panel > button { diff --git a/devplacepy/static/js/components/AppActionMenu.js b/devplacepy/static/js/components/AppActionMenu.js index e5705c84..a7f2a1ad 100644 --- a/devplacepy/static/js/components/AppActionMenu.js +++ b/devplacepy/static/js/components/AppActionMenu.js @@ -83,9 +83,36 @@ export class AppActionMenu extends Component { this.panel.hidden = false; } 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() { + 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")) { this.panel.hidePopover(); } else if (!this.panel.hasAttribute("popover")) { diff --git a/pyproject.toml b/pyproject.toml index 2244a987..402b6106 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "devplacepy" -version = "1.1.21" +version = "1.1.22" description = "DevPlace - The Developer Social Network" requires-python = ">=3.12" dependencies = [