react / react/react-native

Modal UI breaks when using align related CSS properties

未关闭
#52,927 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: Modal Needs: Triage :mag:
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

When the child view of a modal is given alignItems: 'center' or justifyContent: 'center' the UI breaks while the modal is opens.

I could reproduce this behaviour when the modal contains an Image or an SVG, but I've also seen text flickers in the same manner.

While the flicker is prominent in New Architecture, it is also occurring in legacy when trying multiple times.

Steps to reproduce
  1. Make a modal with child view having alignItems: 'center'
  2. Add an Image and a Text to the child View
  3. Flicker occurs when the modal is opened.
React Native Version

0.80.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.5
  CPU: (8) arm64 Apple M1
  Memory: 178.75 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: ~/.nvm/versions/node/v20.18.1/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.1/bin/npm
  Watchman:
    version: 2025.03.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "31"
      - "32"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 28.0.3
      - 30.0.3
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 19.1.1
    wanted: 19.1.1
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.2
    wanted: 0.80.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
Not applicable, since it is a UI bug and nothing is logged as crash
MANDATORY Reproducer

https://github.com/sanyam12/ModalFlicker

Screenshots and Videos

https://github.com/user-attachments/assets/5f8008c6-9982-47c2-bbcd-1ed5566dddfa

Current Behaviour: Modal content is first displayed in top right corner, then at it's intended position.
Expected Behaviour: Modal content should be displayed in the center without any flicker.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 Android 上使用 React Native 0.80.2 运行 github.com/sanyam12/ModalFlicker 中的必需 reproducer,然后比较将 alignItems 或 justifyContent 设置为 center 时 modal 的行为。在 New Architecture 和 legacy mode 下都验证结果;当 modal 内容能够立即居中显示且没有闪烁时即视为完成,包括内容包含 Image、SVG 或 Text 的情况。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, react-native
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。