From 7440dbc3c703475d9380881400c4cdc860c78fa5 Mon Sep 17 00:00:00 2001 From: Danilo Ercoli Date: Thu, 7 Feb 2019 12:52:21 +0100 Subject: [PATCH] [RNMobile] Make placeholder text working on RichText (#13699) * Make placeholder text working again on RichText * Make sure the native side is always refreshed when the RichText component is cleared * Remove placeholder check --- packages/editor/src/components/rich-text/index.native.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/rich-text/index.native.js b/packages/editor/src/components/rich-text/index.native.js index 67d2a86b389574..8a7ce63178eafb 100644 --- a/packages/editor/src/components/rich-text/index.native.js +++ b/packages/editor/src/components/rich-text/index.native.js @@ -360,7 +360,12 @@ export class RichText extends Component { } ) ); // Save back to HTML from React tree - const html = '<' + tagName + '>' + value + ''; + let html = '<' + tagName + '>' + value + ''; + // We need to check if the value is undefined or empty, and then assign it properly otherwise the placeholder is not visible + if ( value === undefined || value === '' ) { + html = ''; + this.lastEventCount = undefined; // force a refresh on the native side + } return ( @@ -373,6 +378,7 @@ export class RichText extends Component { } } text={ { text: html, eventCount: this.lastEventCount } } + placeholder={ this.props.placeholder } onChange={ this.onChange } onFocus={ this.props.onFocus } onBlur={ this.props.onBlur }