facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.19k stars 24.21k forks source link

RN Alert button sometimes renders in the upper-left corner of the screen (iOS) #45453

Open Willham12 opened 2 months ago

Willham12 commented 2 months ago

Description

Previous issue: https://github.com/facebook/react-native/issues/33889

RN Alert button appears on the left top corner.

Steps to reproduce

function openURL(url: string, error: string) {
    Linking.openURL(url).catch(() => showAlert(`${error} ${url}`));
}

function showAlert(
    title: string,
    message?: string,
    buttons?: AlertButton[],
    cancelable = true,
    onDismiss?: () => void
) {
    Alert.alert(title, message, buttons, {
        cancelable: cancelable,
        onDismiss: onDismiss,
        userInterfaceStyle: 'light',
    });

React Native Version

0.74.3

Affected Platforms

Runtime - iOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Memory: 11.83 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.19.0
    path: ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn:
    version: 4.2.2
    path: ~/.nvm/versions/node/v18.19.0/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v18.19.0/bin/npm
  Watchman:
    version: 2024.06.10.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/local/bin/javac
  Ruby:
    version: 3.3.3
    path: /usr/local/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

No crash

Reproducer

https://snack.expo.dev/PLgXKRrgtZIRIjiqFxkR-

Screenshots and Videos

https://github.com/facebook/react-native/issues/33889

rafaelctavares commented 1 week ago

Still happening in 0.75.2 Any updates on this?

bernborgess commented 6 days ago

What is the last version that hadn't this problem? I'm considering downgrading for a temporary fix.

bernborgess commented 6 days ago

This is the current comparison of Alert.alert("Test"); on android vs ios:

Android iOS
wpp image

Not how the "OK" is showing in the upper left corner.

satheeshwaran commented 2 days ago

We are also facing this issue with react-native@0.74.1

native iOS apps also have this issue when trying to present a modal on top of an existing alert

https://stackoverflow.com/questions/27028983/uialertcontroller-is-moved-to-buggy-position-at-top-of-screen-when-it-calls-pre

possible solution: https://stackoverflow.com/a/28731393