Skip to content

fix(rn): 修复双层 fixed 布局导致子节点无法点击的问题#2515

Open
dos1in wants to merge 3 commits into
didi:masterfrom
dos1in:fix/nested-fixed-tap
Open

fix(rn): 修复双层 fixed 布局导致子节点无法点击的问题#2515
dos1in wants to merge 3 commits into
didi:masterfrom
dos1in:fix/nested-fixed-tap

Conversation

@dos1in
Copy link
Copy Markdown
Member

@dos1in dos1in commented Jun 4, 2026

双层 fixed 时,外层和内层都会被各自 portal 到页面根层,原来的父子层级被拆开。发现触摸事件有问题,表现就是按钮不可点击。

可复现 demo:

<view style="position: fixed">
  <view style="position: fixed">
    <view bindtap="...">双层 fixed 内 view bindtap 测试</view>
    <button bindtap="...">双层 fixed 内原生 button bindtap 测试</button>
  </view>
</view>

修复思路:添加 portal z-index 信息。
外层 fixed:portal 到页面根。
内层 fixed:只转成 absolute,保留在外层 fixed 子树内。

  1. fixed 节点生成 stackPath,例如外层 [10002],内层 [10002, 1]。
  2. portal mount/update 时携带 stackPath。
  3. portalManager 对带 stackPath 的 portal 做字典序排序。
  4. 排序后用一层 pointerEvents="box-none" 的 wrapper 分配连续安全 zIndex。
  5. 未携带 stackPath 的普通 portal 保持原挂载顺序。

@hiyuki
Copy link
Copy Markdown
Collaborator

hiyuki commented Jun 4, 2026

保留在子树内定位关系不正确了吧,本身应该是基于root定位,保留在子树内基于子树负容器定位了;还得看一下为啥portal过去会影响点击,一次portal可以为什么二次portal不行

@dos1in
Copy link
Copy Markdown
Member Author

dos1in commented Jun 4, 2026

应该是现在处理方式把原本有层级关系的节点因为 fixed ,现在都变成了兄弟关系的portal,导致影响点击了,我再看看更合适的处理方式。

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.

2 participants