Skip to content

Commit

Permalink
[RNMobile] Make placeholder text working on RichText (#13699)
Browse files Browse the repository at this point in the history
* Make placeholder text working again on RichText

* Make sure the native side is always refreshed when the RichText component is cleared

* Remove placeholder check
  • Loading branch information
daniloercoli authored and youknowriad committed Mar 6, 2019
1 parent cf31537 commit 7440dbc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ export class RichText extends Component {
} ) );

// Save back to HTML from React tree
const html = '<' + tagName + '>' + value + '</' + tagName + '>';
let html = '<' + tagName + '>' + value + '</' + tagName + '>';
// 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 (
<View>
Expand All @@ -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 }
Expand Down

0 comments on commit 7440dbc

Please sign in to comment.