Skip to content

Commit

Permalink
Merge pull request #921 from open-sausages/pulls/1.4/allow-modal-to-r…
Browse files Browse the repository at this point in the history
…ender-html-titlewq

FIX FormSchema field title can include html, this will sometimes be used to render form modals
  • Loading branch information
Maxime Rainville authored Aug 7, 2019
2 parents f0aa1ae + 181dba8 commit 76cc4e7
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 76cc4e7

Please sign in to comment.