Skip to content

Commit

Permalink
FIX FormSchema field title can include html, this will sometimes be u…
Browse files Browse the repository at this point in the history
…sed to render form modals
  • Loading branch information
Maxime Rainville committed Aug 2, 2019
1 parent f0aa1ae commit 181dba8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/vendor.js

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions client/src/components/FormBuilderModal/FormBuilderModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ class FormBuilderModal extends Component {
}

renderHeader() {
if (this.props.title !== false) {
let { title } = this.props;

if (title !== false) {
if (typeof title === 'object') {
// FormSchema title occasionaly contains html, only render text for modal title
const doc = new DOMParser().parseFromString(title.html, 'text/html');
title = doc.body.textContent || '';
}
return (
<ModalHeader toggle={this.handleHide}>{this.props.title}</ModalHeader>
<ModalHeader toggle={this.handleHide}>{title}</ModalHeader>
);
}

Expand Down Expand Up @@ -188,7 +195,11 @@ class FormBuilderModal extends Component {
FormBuilderModal.propTypes = {
autoFocus: PropTypes.bool,
isOpen: PropTypes.bool,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.shape({ html: PropTypes.string })
]),
className: PropTypes.string,
bodyClassName: PropTypes.string,
modalClassName: PropTypes.string,
Expand Down

0 comments on commit 181dba8

Please sign in to comment.