menu: Fix render nested submenus with increasing paint priority (#2587)
## Description Nested submenus were drawn as plain `anchored()` elements that shared the same paint order, so shallow-level content (e.g. the underlying list behind the menu) could show through deeper submenu panels. This change gives each `PopupMenu` a `priority: usize` field (top-level = 1) that increments by one for every nested level, and wraps both the menu body and its submenu panels in `deferred().with_priority(priority)`: - `PopupMenu::render()` now returns `deferred(menu).with_priority(self.priority)` so the top-level menu is itself a deferred layer. - Each submenu panel is rendered with `.with_priority(self.priority + 1)`. - `submenu_with_icon` propagates `priority = parent_priority + 1` down the tree. The result is a strict paint order: top-level (1) < submenu (2) < sub-submenu (3) < ..., so deeper menus always paint on top of shallower ones. ## Screenshot | Before | After | | ---------------------------- | --------------------------- | | [<img width="500" height="163" alt="before" src="https://github.com/user-attachments/assets/0da6b4c2-b26c-4cb8-9e19-ef77e362bcd0" />] | [<img width="500" height="163" alt="after" src="https://github.com/user-attachments/assets/55f3dd49-f51d-4fb8-8d23-7b658f08bf43" />] | ## How to Test 1. To reproduce the multi-level paint-order bug, a menu with **at least two nested submenu levels** is required (e.g. a right-click tree where each item opens a submenu that itself contains another submenu). Expand several levels so deeper panels overlap shallower ones. 2. **Before:** shallow-level text was visible through deeper submenu panels (see the *Before* screenshot). 3. **After:** deeper submenus always paint on top, so background text no longer bleeds through (see the *After* screenshot). ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [x] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) --------- Co-authored-by: Lumen <haifeng_dai_cn@163.com> Co-authored-by: Jason Lee <huacnlee@gmail.com>
L
Lumen committed
bc174a7ec4534b2a4174fddde314b38d30d69093
Parent: f79f0ef
Committed by GitHub <noreply@github.com>
on 7/24/2026, 9:25:22 AM