mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3069] [Issue]: Game-assets toolbar New/Columns dropdowns open at the button's left edge with no viewport clamp, so they run off the right screen edge on narrow phones #1637
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1637
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3069
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
In the Game Assets toolbar, the "New" file dropdown and the "Columns" dropdown (list view) are portaled to
document.bodyand positioned with a fixedleftequal to the button's left edge, plus a minimum width of 10rem (160px), with no horizontal clamping against the viewport. On a phone the toolbar action buttons sit in aflex-wraprow and can land near the right edge of the screen. When that happens, the menu extends 160px+ to the right of the button and runs off the right side of the viewport, clipping menu items (e.g. "New markdown file") under the screen edge and/or forcing horizontal overflow. Other comparable portaled menus in the app already clamp themselves into the viewport, so this one is inconsistent. This is mobile-only because on desktop the buttons are never close enough to the right edge for the clamp to matter.How to reproduce (try it yourself)
You'll see: the dropdown opens flush against the button's left edge and its right side is cut off by the screen edge, hiding or clipping the menu options (e.g. "New markdown file").
Expected: the dropdown shifts left as needed to stay fully inside the viewport, the way the source menu and folder-selection menu already do.
Where it is
packages/client/src/components/game-assets/Toolbar.tsx:125-128sets the New menu position to the raw button left with no clamp:Toolbar.tsx:131-134(openCols) is the identical pattern for the Columns menu. Both are rendered by thedropdownhelper atToolbar.tsx:144-153, which portals todocument.body:So the menu is fixed-positioned, at least 160px wide, anchored at the raw button left, with nothing pulling it back into the viewport.
Siblings that do it right (same codebase):
GameAssetsBrowserView.tsx:179clampsx: Math.max(8, Math.min(rect.left, window.innerWidth - 288)), andBotBrowserView.tsx:1410-1413clampsleft = Math.min(Math.max(SOURCE_MENU_MARGIN, rect.left), Math.max(SOURCE_MENU_MARGIN, window.innerWidth - width - SOURCE_MENU_MARGIN)). The Toolbar dropdowns lack any equivalent.What's happening
leftis set to the rawrect.leftof the button with noMath.minagainstwindow.innerWidth - menuWidth - margin. When a button sits near the right edge of a narrow viewport, the menu's right edge (left + >=160px) exceedswindow.innerWidth, so the overflowing portion is clipped under the right screen edge. Because the position is an inlinestyle.left, no CSS media query can rescue it — there's no custom class hook on the portaled element (it carries only Tailwind utilities), and the inline style would override CSSleftanyway. The buttons genuinely render on mobile: the Columns button appears wheneverviewMode === "list", and the New button always renders (only its text span ismax-sm:hidden, so the icon button still shows in theflex flex-wrapactions row). The toolbar's container is full-width on phones (.app-right-panel-mobileiswidth: 100% !importantin globals.css), so there is no surrounding max-width to keep the button off the edge.Suggested fix
Clamp
xin bothopenNewandopenColsagainst the viewport, matching the sibling menus. Add module-level constantsconst TOOLBAR_MENU_WIDTH = 176;(11rem — covers themin-w-[10rem]=160px menu plus the widest item "New markdown file" with its icon andpx-3padding) andconst TOOLBAR_MENU_MARGIN = 8;, then:Using a concrete width constant (rather than an unmeasured placeholder) keeps this consistent with
GameAssetsBrowserView.tsx:179, which also hardcodes its menu width. An optionalmaxHeightclamp againstwindow.innerHeightcan be added but is not load-bearing for this horizontal-overflow bug.Regression avoided: this is a pure JS clamp on the inline
leftvalue computed fromwindow.innerWidth. It touches no Tailwind classes (nomax-md:/max-sm:leak), no z-index, no hover/visibility state, and does not reflow the flex actions row, so desktop and all other breakpoints are unaffected. On wide/desktop viewportsrect.leftis far belowwindow.innerWidth - TOOLBAR_MENU_WIDTH - TOOLBAR_MENU_MARGIN, soMath.minreturnsrect.leftunchanged — identical to current behavior. Only positional math changes, so light/dark/sillytavern themes are untouched. It mirrors the already-shipped clamps in the same files, making the codebase more consistent, not less.AI-investigated against v2.0.6 (packages/client); cited lines read and confirmed. Mobile layout verified by reading the computed Tailwind classes + globals.css, not on a device — please confirm on a phone before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Addressed in PR #3072 by commit
4146a380. Validated locally with pnpm check and pnpm smoke:ui.