diff --git a/src/renderers/Form/SubForm.tsx b/src/renderers/Form/SubForm.tsx index 80c6ddcfa..4b6ca3205 100644 --- a/src/renderers/Form/SubForm.tsx +++ b/src/renderers/Form/SubForm.tsx @@ -146,7 +146,9 @@ export default class SubFormControl extends React.PureComponent - {(value && labelField && value[labelField] && stripTag(value[labelField])) || - btnLabel} + {(value && labelField && value[labelField] && stripTag(value[labelField])) + || render('placeholder', + { + type: 'tpl', + tpl: btnLabel + }, + { + data + })} )) @@ -199,7 +208,7 @@ export default class SubFormControl extends React.PureComponent @@ -216,7 +225,16 @@ export default class SubFormControl extends React.PureComponent - {(value && labelField && value[labelField] && stripTag(value[labelField])) || btnLabel} + {(value && labelField && value[labelField] && stripTag(value[labelField])) + || render('placeholder', + { + type: 'tpl', + tpl: btnLabel + }, + { + data + } + )}} diff --git a/src/renderers/IFrame.tsx b/src/renderers/IFrame.tsx index 61adbb262..069085bcf 100644 --- a/src/renderers/IFrame.tsx +++ b/src/renderers/IFrame.tsx @@ -1,6 +1,8 @@ import React from 'react'; import {Renderer, RendererProps} from '../factory'; import {filter} from '../utils/tpl'; +import {autobind} from '../utils/helper'; +import {ScopedContext, IScopedContext} from '../Scoped'; export interface IFrameProps extends RendererProps { className?: string; @@ -8,6 +10,7 @@ export interface IFrameProps extends RendererProps { } export default class IFrame extends React.Component { + IFrameRef: React.RefObject = React.createRef(); static propsList: Array = ['src', 'className']; static defaultProps: Partial = { className: '', @@ -16,6 +19,11 @@ export default class IFrame extends React.Component { frameBorder: 0 }; + @autobind + reload() { + (this.IFrameRef.current as HTMLIFrameElement).src = (this.IFrameRef.current as HTMLIFrameElement).src; + } + render() { let {className, src, width, height, frameBorder, data, style} = this.props; @@ -31,6 +39,7 @@ export default class IFrame extends React.Component { className={className} frameBorder={frameBorder} style={style} + ref={this.IFrameRef} src={src ? filter(src, data) : undefined} /> ); @@ -41,4 +50,16 @@ export default class IFrame extends React.Component { test: /(^|\/)iframe$/, name: 'iframe' }) -export class IFrameRenderer extends IFrame {} +export class IFrameRenderer extends IFrame { + static contextType = ScopedContext; + + componentWillMount() { + const scoped = this.context as IScopedContext; + scoped.registerComponent(this); + } + + componentWillUnmount() { + const scoped = this.context as IScopedContext; + scoped.unRegisterComponent(this); + } +}