react / react/react-native

Nested View and Text vertical alignment issue.

オープン
#31,955 コメント 23 件 リアクション 24 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Triage :mag:
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

Nesting View inside Text adds lineHeight's marginBottom to View and when we add Text inside that View it doesn't gets aligned properly.

React Native version:

System:
OS: macOS 11.4
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 55.67 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.10 - ~/npm-global/bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: ~0.63.4 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

  1. Setup a CRNA or Expo app.
  2. Replace the code in App.js with -
import { StatusBar } from "expo-status-bar";
import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default function App() {
  return (
    <View style={styles.container}>
      <Text style={styles.outsideText}>
        Outside Text{" "}
        <View style={styles.insideView}>
          <Text>Inside Text</Text>
        </View>
      </Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
  outsideText: {
    backgroundColor: "#cecece",
  },
  insideView: {
    backgroundColor: "#fcc9",
  },
});
  1. Start your App on iOS or Android with yarn ios or yarn android.

Expected Results

The text should be in the same line aligned vertically. Like it looks when we run this example on the Web.

Snack, code example, screenshot, or link to a repository:

https://snack.expo.dev/gdbQbTirc
Screenshot 2021-08-05 at 1 40 11 AM

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issue の App.js 例にある配置の問題を、リンクされた Snack または CRNA/Expo アプリを使い、yarn ios または yarn android を実行して再現します。Text 内にネストされた View が iOS と Android で lineHeight と垂直レイアウトをどのように処理するかを追跡します。ネストされた Inside Text が同じ行に表示され、Outside Text と垂直方向に揃えば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。