react / react/react-native

[Android] Empty title / message in Alert.alert causes extra spacing

未关闭
#53,627 11 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

API: Alert Needs: Attention Needs: Repro Platform: Android
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

On Android, passing an empty string ("") for either the title or the message in Alert.alert results in visible empty space being rendered in the dialog.

Steps to reproduce

Case 1: Empty title

Alert.alert("", "Message", [
  { text: "OK", onPress: () => {} },
]);

Case 2: Empty message

Alert.alert("Warning", "", [
  { text: "OK", onPress: () => {} },
]);

Case 3: Both empty

Alert.alert("", "", [
  { text: "OK", onPress: () => {} },
]);
React Native Version

0.80.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6.1
  CPU: (8) arm64 Apple M3
  Memory: 125.22 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.15.0
    path: ~/.nvm/versions/node/v20.15.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v20.15.0/bin/npm
  Watchman:
    version: 2024.11.25.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/meetkapadiya/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13991807
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 2.7.4
    path: /Users/meetkapadiya/.rvm/rubies/ruby-2.7.4/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
MANDATORY Reproducer

https://snack.expo.dev/@meetkapadiya/alert-demo?platform=android

Screenshots and Videos
Image

贡献指南

打开贡献指南

从这里开始

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

调研方向

从必需的 Snack reproducer 开始,检查 Alert.alert 的 Android 实现。验证标题为空、消息为空以及两个值都为空时的行为,然后跟踪导致额外间距的对话框布局。当这三种情况都能在没有非预期空白的情况下渲染,并且该行为已由回归测试覆盖时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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