组件内部 zIndex 抬升子树排序键,根级浮层(scrim/下拉菜单)失去命中与绘制优先级
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- desktop-dev
Research direction
Start in components/slider.h, where the .hit rect is built with a hard-coded zIndex, and check how rebuildOrderedElements in core/dsl.h sorts children by subtreeMaxZIndex. The regression test is tests/unit/slider_subtree_z_order.cpp; build and run it first to see the failing assertion. Done when page->subtreeMaxZIndex is 0 and the overlay sorts after the page, so the test passes without changing other slider behavior.
Written by the indexing model from the issue text.
Description
现象
宿主应用(节点编辑器画布)中,页面内容包含滑条组件后,合成在其后的根级浮层——全窗口 scrim 与下拉菜单面板——完全失去命中优先级:点击 scrim/菜单项时,事件落到页面底层的输入区(画布 mouseArea),浮层被意外收起、菜单项永远无法选中。绘制序同样被压到页面之下。
宿主真机 A/B 实证(同一画布、同一浮层代码,唯一变量是页面内是否存在滑条参数节点):
- 页面含滑条节点 → 点击浮层菜单项的坐标,事件穿透到画布输入区;
- 页面不含滑条节点(无参数的节点)→ 同一坐标由 scrim 正确拦截并收起浮层。
根因
命中测试与绘制的遍历顺序按 orderedChildren / orderedRoots 排序,排序键是 subtreeMaxZIndex(core/dsl.h 的 rebuildOrderedElements,升序排序、命中逆序遍历)。
而 components/slider.h 的内部热区自带硬编码 zIndex:
ui_.rect(id_ + ".hit")
.size(width_, height_)
.states(...)
.zIndex(10) // ← 抬升整个滑条子树的排序键
.interactive()
.sliderInputFrom(id_)
.build();
滑条栈内 .hit 的输入优先级本就由合成序保证(栈内最后一个子元素,逆序命中时最先被测试),这个 zIndex(10) 没有栈内收益,却把页面子树的 max z 抬到 10——所有默认 z=0 的根级浮层在根级兄弟排序中被排到页面之后(命中先测试页面、绘制后画页面),浮层即失效。
两个连带推论:
- 由于排序只看 z 不看合成序,浮层即便晚于页面合成也无法挽回;
- 同理,滑条所在子树还会压过其后合成的兄弟子树中 z=0 的交互元素(如后画到滑条上方的卡片控件),不只是根级浮层场景。
最小复现(单元级)
root stack → page stack(内含一个 components::slider)→ overlay rect(onClick,z 默认 0,后合成)。
ui.layout(...) 后:page->subtreeMaxZIndex == 10,且 root 的 orderedChildren 中 overlay 被排到 page 之前——逆序命中遍历先测 page。修复后两者均为 0、稳定序保持合成序(overlay 在后,逆序命中先达)。
(已随修复提交回归测试 tests/unit/slider_subtree_z_order.cpp:修复前该测试在第一条断言失败——slider inflates page subtreeMaxZIndex to 10。)
影响
凡页面内容包含滑条,宿主的模态浮层(下拉、右键菜单、scrim)、以及页面上后合成的 z=0 交互控件,命中与绘制都被滑条子树压过。组件库若未来有更多组件内部使用 zIndex,同类风险会扩大。
建议修复
移除 slider.h .hit 的 .zIndex(10)(其栈内优先级由合成序保证,行为不变)。随后提 PR,附上述回归测试。
- Dominant language
- C++
- Stars
- 2k
- Forks
- 177
- Avg merge
- 19h 58m
- Merged PRs (30d)
- 9
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sudoevolve/EUI-NEO
-
Difficulty 5/5 Over a week Newbie friendliness 18/100
sudoevolve/EUI-NEO#89 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sudoevolve/EUI-NEO#45 · 5 comments ·
Maintainers usually reply within 2 days
-
关于安卓demo的讨论Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sudoevolve/EUI-NEO#44 · 1 comment ·
Maintainers usually reply within 2 days
All issues in sudoevolve/EUI-NEO
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mesonbuild/wrapdb#2961 ·
Maintainers usually reply within 1 day
-
80 Instance - Raid - Northrend
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
azerothcore/azerothcore-wotlk#28075 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
objectionary/eo-graphs#80 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
scanaislop/aislop#476 ·
Maintainers usually reply within 1 day