diff --git a/src/components/Widgets/ControlHOC.js b/src/components/Widgets/ControlHOC.js index d9d6fbba8bdf..5016cb39e7ec 100644 --- a/src/components/Widgets/ControlHOC.js +++ b/src/components/Widgets/ControlHOC.js @@ -36,8 +36,17 @@ class ControlHOC extends Component { return this.props.value !== nextProps.value; } - processInnerControlRef = (wrappedControl) => { - if (!wrappedControl) return; + processInnerControlRef = ref => { + if (!ref) return; + + /** + * If the widget is a container that receives state updates from the store, + * we'll need to get the ref of the actual control via the `react-redux` + * `getWrappedInstance` method. Note that connected widgets must pass + * `withRef: true` to `connect` in the options object. + */ + const wrappedControl = ref.getWrappedInstance ? ref.getWrappedInstance() : ref; + this.wrappedControlValid = wrappedControl.isValid || truthy; /** diff --git a/src/components/Widgets/RelationControl.js b/src/components/Widgets/RelationControl.js index 1e2d0aaf4dca..0b7a15c99181 100644 --- a/src/components/Widgets/RelationControl.js +++ b/src/components/Widgets/RelationControl.js @@ -128,5 +128,9 @@ export default connect( { query, clearSearch, + }, + null, + { + withRef: true, } )(RelationControl);