Skip to content

Keep nested dropdown menus on screen - #7168

Merged
shimmyshimmer merged 4 commits into
mainfrom
agent/fix-compact-chat-submenus
Jul 16, 2026
Merged

shimmyshimmer merged 4 commits into
mainfrom
agent/fix-compact-chat-submenus

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Apply compact submenu overlap behavior in the shared dropdown submenu primitive.
  • Measure each submenu's untransformed layout width and derive its compact offset from that width.
  • Cover composer menus, chat sidebar menus, Projects menus, Settings > Chat export menus, and future nested dropdown consumers.
  • Cap nested menu width to the viewport on very narrow screens.
  • Preserve each caller's existing side offset and cascading placement on desktop widths.
  • Add regression contracts for the shared compact behavior.

Root cause

Parent menus are commonly 176 to 244 pixels wide and nested menus are 208 to 300 pixels wide. On narrow screens, neither side has enough space for a full cascade. Collision handling selected the side with less overflow, but part of the nested menu could remain outside the viewport.

The initial compact workaround used one fixed offset for menus of several widths. That assumption could over-shift narrower menus and did not adapt when a submenu was resized or capped by the viewport. Measuring transformed bounds during the opening animation could also understate the final width.

Impact

Nested actions remain visible and clickable on compact screens across the chat UI. Each submenu now overlaps by its own rendered width, including collision-disabled menus and right-to-left layouts. Desktop behavior is unchanged because the shared primitive passes through every existing desktop sideOffset.

Validation

  • Verified More, Saved prompts, Projects, Export, and Bypass permissions at compact widths.
  • Verified normal cascading placement at 800 pixels.
  • Audited every DropdownMenuSubContent consumer in the frontend.
  • Ran 966 geometry simulations across current parent and submenu widths, 240 to 1024 pixel viewports, both text directions, collision-disabled consumers, viewport width caps, resizes, opening transforms, and the 767/768 pixel breakpoint.
  • Ran 39 related UI contract tests.
  • Ran the new regression contracts on Python 3.10, 3.11, 3.12, and 3.13 in isolated uv environments.
  • Ran frontend typecheck and production builds on Node 20, 22, and 24.
  • Recorded 1,207 passing Studio tests in the expanded sandbox, then reran 23 load and timing tests and 23 hardware dispatch tests independently with all passing.
  • Ran targeted ESLint on the shared dropdown primitive.
  • Ran npm run typecheck.
  • Ran npm run build.
  • Ran npm run i18n:check.
  • Ran the lockfile, dependency-removal, and script-pin audits.
  • Ran git diff --check.

Notes

The failing Backend CI Python jobs reproduce on current main and are unrelated to this frontend change. PR #7169 fixes the incomplete DeepSeek reasoning test shim that causes those failures.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces responsive adjustments for dropdown submenus on mobile screens by utilizing the useIsMobile hook to conditionally apply a negative offset (-248) to several DropdownMenuSubContent components across thread.tsx, bypass-permissions-menu-item.tsx, and shared-composer.tsx. The review feedback suggests adding comments to explain the relationship between this magic number offset and the parent menu's width to improve maintainability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

side = "bottom",
}) => {
const navigate = useNavigate();
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The offset -248 is a magic number that depends on the parent menu's width (w-[244px]). Adding a comment explaining this relationship improves maintainability and helps future developers if the parent menu width is ever adjusted.

Suggested change
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;
// Offset to shift submenus back over the parent menu (w-[244px]) on mobile/compact screens
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

model2ThreadId?: string;
}): ReactElement {
const navigate = useNavigate();
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The offset -248 is a magic number that depends on the parent menu's width (w-[244px]). Adding a comment explaining this relationship improves maintainability and helps future developers if the parent menu width is ever adjusted.

Suggested change
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;
// Offset to shift submenus back over the parent menu (w-[244px]) on mobile/compact screens
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

// driven by the store), so it survives the menu unmounting and the "+"/More
// popovers don't stay frozen.
export function BypassPermissionsMenuItem() {
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The offset -248 is a magic number that depends on the parent menu's width (w-[244px]). Adding a comment explaining this relationship improves maintainability and helps future developers if the parent menu width is ever adjusted.

Suggested change
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;
// Offset to shift submenus back over the parent menu (w-[244px]) on mobile/compact screens
const compactSubmenuOffset = useIsMobile() ? -248 : undefined;

@shimmyshimmer shimmyshimmer changed the title Keep compact chat submenus on screen Keep nested dropdown menus on screen Jul 16, 2026
@shimmyshimmer
shimmyshimmer marked this pull request as ready for review July 16, 2026 08:39
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed66c15a45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (!element) return;

const updateContentWidth = () => {
setContentWidth(element.getBoundingClientRect().width);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use untransformed submenu width for compact offset

On mobile, this measures getBoundingClientRect().width while the submenu is opening with the data-open:zoom-in-95 transform applied below, so the stored width is about 95% of the menu's final visual width. ResizeObserver does not fire for transform-only animation changes, so when a submenu opens flush against the right edge the final menu can grow past the viewport by the missing ~5% even though sideOffset was intended to overlap by the full rendered width; measuring layout width (for example offsetWidth) or remeasuring after the animation avoids the residual overflow.

Useful? React with 👍 / 👎.

@shimmyshimmer
shimmyshimmer merged commit fb7381f into main Jul 16, 2026
35 of 41 checks passed
@shimmyshimmer
shimmyshimmer deleted the agent/fix-compact-chat-submenus branch July 16, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant