From bcf2e329ed1e481db1cd1d37d36ca290f9800762 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Mon, 15 Aug 2016 14:27:40 -0700 Subject: [PATCH] Fix RCTText not always drawing in Nodes Summary: In Nodes, there were certain cases where text wasn't drawn due to an optimization that skipped measuring because the size was already known. Reviewed By: emilsjolander Differential Revision: D3713841 --- .../java/com/facebook/react/flat/RCTText.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java index ef9411033..c5a67eec0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java @@ -134,8 +134,19 @@ import com.facebook.textcachewarmer.DefaultTextLayoutCacheWarmer; clipBottom); if (mText == null) { - // nothing to draw (empty text). - return; + // as an optimization, LayoutEngine may not call measure in certain cases, such as when the + // dimensions are already defined. in these cases, we should still draw the text. + if (bottom - top > 0 && right - left > 0) { + CharSequence text = getText(); + if (!TextUtils.isEmpty(text)) { + mText = text; + } + } + + if (mText == null) { + // nothing to draw (empty text). + return; + } } boolean updateNodeRegion = false;