react / react/react-native

Modal UI breaks when using align related CSS properties

Offen
#52,927 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Component: Modal Needs: Triage :mag:
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Führen Sie zunächst den obligatorischen Reproducer unter github.com/sanyam12/ModalFlicker auf Android mit React Native 0.80.2 aus und vergleichen Sie anschließend das Modal-Verhalten, wenn alignItems oder justifyContent auf center gesetzt ist. Überprüfen Sie das Ergebnis sowohl in der New Architecture als auch im legacy mode; abgeschlossen ist die Aufgabe, wenn der Inhalt des Modals sofort ohne Flackern zentriert erscheint, auch wenn er ein Image, SVG oder Text enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.