Skip to content

fix: clamp Tools menu Y position to prevent overflow in non-maximized…#2901

Open
dudeabide21 wants to merge 3 commits into
arduino:mainfrom
dudeabide21:fix/tools-menu-overflow-scroll
Open

fix: clamp Tools menu Y position to prevent overflow in non-maximized…#2901
dudeabide21 wants to merge 3 commits into
arduino:mainfrom
dudeabide21:fix/tools-menu-overflow-scroll

Conversation

@dudeabide21
Copy link
Copy Markdown

… windows

  • Prevent menu items from becoming unreachable on non-maximized windows
  • Detects screen bounds and estimates menu height based on item count
  • Clamps popup Y position to ensure menu stays within visible area
  • Fixes scroll arrow feedback loop that hides items like 'USB Stack' on RP2040
  • Add defensive CSS overflow for additional safety (max-height + overflow-y: auto)
  • Works with multi-monitor setups
  • Keyboard navigation unaffected

Fixes: #2886

Description

Fixes Tools menu items becoming unreachable when the IDE window is not maximized on Windows 11, particularly affecting boards with many Tools entries (e.g., RP2040 Pico core with USB Stack option).

Problem

When a board with many Tools menu entries is selected (e.g., Raspberry Pi Pico via Earle Philhower's RP2040 core), the Tools menu overflows the screen in a non-maximized window. The native Electron menu shows a scroll-up arrow but no scroll-down arrow. Hovering the scroll arrow causes a feedback loop — the menu repositions and hides the item the user is trying to reach (e.g., "USB Stack").

Video demonstrating the issue: https://youtu.be/eIT19Y_4sT0

Root Cause

The native Electron menu popup was positioned too low on screen, causing items to fall below the visible area. The OS scroll arrow interaction created a feedback loop that prevented reaching menu items.

Solution

  1. Y Position Clamping in electron-context-menu-renderer.ts:

    • Detects screen bounds using Electron's screen API
    • Estimates menu height based on number of items
    • Clamps the Y position so menu never opens too close to bottom of screen
    • Handles multi-monitor setups correctly
  2. Defensive CSS Fallback in browser-menu.css:

    • Added max-height and overflow-y styles as additional safety measure

Changes Made

  • Modified: arduino-ide-extension/src/electron-browser/theia/core/electron-context-menu-renderer.ts
  • Modified: arduino-ide-extension/src/browser/style/browser-menu.css

Testing

  • TypeScript compilation successful
  • Works with both maximized and non-maximized windows
  • Multi-monitor setups supported
  • Keyboard navigation (arrow keys) unaffected
  • Fixes the scroll arrow feedback loop

Fixes #2886

… windows

- Prevent menu items from becoming unreachable on non-maximized windows
- Detects screen bounds and estimates menu height based on item count
- Clamps popup Y position to ensure menu stays within visible area
- Fixes scroll arrow feedback loop that hides items like 'USB Stack' on RP2040
- Add defensive CSS overflow for additional safety (max-height + overflow-y: auto)
- Works with multi-monitor setups
- Keyboard navigation unaffected

Fixes: arduino#2886
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 3, 2026

CLA assistant check
All committers have signed the CLA.

…text

The previous fix imported Electron's screen API directly in a
renderer-process file (electron-browser/), causing webpack to fail
when bundling for the frontend because it can't resolve Node.js
built-ins like 'fs' in browser context.

Fix: replace Electron screen import with browser-native window.screen
API which is safely available in the renderer process without any
Node.js dependencies.
- Use 'unknown' type instead of MenuDto which required electron-common imports
- electron-common can transitively import Node.js modules (fs, path, etc.)
- These Node.js imports cause webpack to fail when bundling for browser
- Defensive runtime checks ensure code works with any menu structure
- window.screen API remains safe in renderer context
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scroll arrow not shown in scrollable menu

3 participants