Skip to content

Commit

Permalink
Merge pull request #592 from shoutem/release/4.4.3
Browse files Browse the repository at this point in the history
Release/4.4.3
  • Loading branch information
tomislav-arambasic authored May 10, 2021
2 parents e19a7b3 + 7c26cc6 commit 4324019
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions html/components/SimpleHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ class SimpleHtml extends PureComponent {
return false;
}

/**
* Removes child break node in case when it's positioned at the end
* of parent div node and div has content in it.
* Example:
* <div>first line<br></div>
* <div>second line<br></div>
*
* If br is left as is, <Html> will show empty line under div, not just
* break into new line
*/
alterChildren(node) {
const { children, name } = node;

if ((name === 'div' || name === 'p') && children && children.length > 1) {
const brNodes = _.filter(children, { name: 'br' });
const lastBrNode = _.last(brNodes);

if (lastBrNode && lastBrNode.next === null) {
const lastBrNodeIndex = _.indexOf(children, lastBrNode);
return children.splice(0, lastBrNodeIndex);
}
}

return children;
}

renderUnorderedListPrefix() {
const { style } = this.props;

Expand Down Expand Up @@ -113,6 +139,7 @@ class SimpleHtml extends PureComponent {
ignoredStyles: ['font-family', 'letter-spacing', 'transform'],
onLinkPress: this.onLinkPress,
alterNode: this.alterNode,
alterChildren: this.alterChildren,
listsPrefixesRenderers: listPrefixRenderers,
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shoutem/ui",
"version": "4.4.2",
"version": "4.4.3",
"description": "Styleable set of components for React Native applications",
"scripts": {
"lint": "eslint .",
Expand Down

0 comments on commit 4324019

Please sign in to comment.