Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picker 组件的蒙层和选择器应该渲染到 body 里面而不是当前上下文 #8586

Closed
ppbl opened this issue Jan 26, 2021 · 1 comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@ppbl
Copy link

ppbl commented Jan 26, 2021

相关平台

H5

复现仓库

暂无

浏览器版本: chrome 88
使用框架: React

复现步骤

  1. 使用 swiper 组件
  2. swiper 组件里面使用picker 组件

期望结果

picker 正常相对于窗口定位

实际结果

遮罩层被限制在 swiper 里面

原因

swiper 组件内使用了 transform 属性,影响了 picker 组件的 fixed 定位

解决方法

picker 组件的蒙层渲染到 body 里面可以解决此问题

环境信息

Taro CLI 3.0.24 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.6.0 - /opt/homebrew/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 7.4.0 - /opt/homebrew/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.24 => 3.0.24 
      @tarojs/components: 3.0.24 => 3.0.24 
      @tarojs/mini-runner: ^3.0.24 => 3.0.24 
      @tarojs/react: 3.0.24 => 3.0.24 
      @tarojs/runtime: 3.0.24 => 3.0.24 
      @tarojs/taro: 3.0.24 => 3.0.24 
      @tarojs/webpack-runner: 3.0.24 => 3.0.24 
      babel-preset-taro: 3.0.24 => 3.0.24 
      eslint-config-taro: 3.0.24 => 3.0.24 
      react: ^17.0.1 => 17.0.1 
      taro-ui: ^3.0.0-alpha.9 => 3.0.0-alpha.9 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Jan 26, 2021
@ppbl
Copy link
Author

ppbl commented Jan 26, 2021

大概原因是 swiper 组件中使用的 transform 属性影响到了 picker 组件的 fixed 定位

picker 组件的蒙层渲染到 body 里面的话应该就可以解决这个问题

(似乎使用 custom element 的话,不像 react 有 Portal 这么方便。。。 )

@ppbl ppbl changed the title swiper 组件内使用 position: fixed 不能相对窗口定位,看起来像是相对于 swiper 的 picker 组件的蒙层和选择器应该渲染到 body 里面而不是当前上下文 Jan 26, 2021
@SyMind SyMind mentioned this issue Feb 20, 2021
20 tasks
@ppbl ppbl closed this as completed Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

1 participant